The biggest fun of lottery is not in receiving the (usually a tiny amount of) prize money, but in dreaming of the big fortune you may possibly (that is, virtually never) receive.
You have a number of lottery tickets at hand, each with a six-digit number. All the numbers are different, of course. Tomorrow is the drawing day and the prizes are the following.
The six digits on the lottery tickets and all of the winning numbers may start with zeros.
The last two digits of all the prize winning numbers are made different so that tickets winning the third prize cannot also win the first nor the second prizes. Note that this rule also made the last two digits of the first and the second prize winning numbers different.
To enjoy the climax of the lottery fun time, you decided to calculate the possible maximum amount you may win with your tickets. You have too many tickets to hand-calculate it, but it should also be your joy to write a program for making the calculation.
The first line of the input has a positive integer n (n≤105), which is the number of tickets you have at hand. Each of the following n lines has the six-digit number on one of your tickets. All the n numbers are different from one another.
Output in a line a single integer, which is the maximum possible total of winning prizes with the tickets you have.
For the first sample, the following combination of prize winners allows the maximum total amount of 309500 yen.
For the second sample, nine out of the ten tickets have the same last two digits, 89, and thus the third prize winner of 89 allows nine third prizes, totaling 4500 yen. This is more than the second prize of 4000 yen possibly won by one of these nine tickets. The only remaining ticket 263784 should, of course, win the first prize.