Limits 1s, 512 MB

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.


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

1N1051 \le N \le 10^5

0X1090 \le X \le 10^9


Print the sum of all the XX in our traditional number system.



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

Thus, the sum is (25 + 17) = 42.


Login to submit.


71% Solution Ratio
itstanmaykumarEarliest, Jul '22
steinumFastest, 0.0s
IU_SpiralForgeLightest, 5.4 kB
Nusab19Shortest, 133B
Toph uses cookies. By continuing you agree to our Cookie Policy.