Lost Exponents

Split each integer into a base from all but the last digit and an exponent from the last digit, then print the sum of the powers.

Easy2MathImplementationInterviewNo attempts yetTime limit1sMemory limit64 MB

Problem

A teacher emailed her students the following task.

"Write a program that reads the expression X=number1pot1+number2pot2++numberNpotNX = number_1^{pot_1} + number_2^{pot_2} + \dots + number_N^{pot_N} and prints the value of XX. Every number1number_1 through numberNnumber_N is an integer, and every pot1pot_1 through potNpot_N is a one-digit integer."

While the teacher downloaded the file to her computer, the text formatting was lost and the task turned into a plain sum of NN integers.

X=P1+P2++PNX = P_1 + P_2 + \dots + P_N

For example, once the formatting was gone, the original X=212+1253X = 21^2 + 125^3 became X=212+1253X = 212 + 1253. Given the integers P1P_1 through PNP_N of the damaged expression, compute and print the value of XX from the original task.

Here aNa^N means aa multiplied by itself NN times, and a0=1a^0 = 1.

Input

The first line contains the integer NN (1N101 \le N \le 10), the number of addends in the task.

Each of the next NN lines contains one integer PiP_i (10Pi999910 \le P_i \le 9999, i=1Ni = 1 \dots N) from the damaged expression.

Output

Print the value of XX from the original task on a single line. The input always satisfies X109X \le 10^9.

Hint

The last digit of each PiP_i is the exponent and everything in front of it is the base. For example, Pi=573P_i = 573 means 573=18519357^3 = 185193.

When PiP_i has two digits, the base is a single digit. When the last digit is 0, the exponent is 0 and the addend is worth 1.