Mr. Masud is a superstitious executive of an administrative office in Wadia, and you have to bribe him to provide you with certain services. But the problem is, his superstitions are always a bit unconventional. That is the reason he is popularly known as "Ulta Masud." Usually, people consider the number 7 as lucky. But being an unconventional guy, Masud considers this an unlucky digit. So in his bribe invoices, he maintains all the transaction amounts in a manner where he doesn't use the number 7 at all. So he counts numbers like this: 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, …

Now, you need some of the services mentioned earlier from him, and he has sent you a list of the prices for those services. But the costs are written in his weird number system that excludes the digit 7. Now your task is to sum those weirdly formatted numbers and convert them to the traditional number we use.

Input

The first line of input will contain a number $N$. The next $N$ line will contain a number $X$, written in the mentioned 7-less system. The numbers may contain leading zeros.

$1 \le N \le 10^5$

$0 \le X \le 10^9$

Output

Print the sum of all the $X$ in our traditional number system.

Sample

Input

Output

2
19
28

42

28 in Masud’s representation is 25 in ours, and 19 in his is 17 in ours.