Time limit
2s
Memory limit
128 MB
You are given N numbers. Every number is a positive integer, but its decimal digits have been replaced by the letters A through J. Each letter represents exactly one digit, and each digit is represented by exactly one letter. No number starts with 0. Determine the maximum possible sum of the N numbers.
The first line contains N, a positive integer no greater than 50. Each of the next N lines contains one number. The length of each number is at most 12. At least one letter never appears as the first character of a number.
Print the maximum possible sum.