eolymp
bolt
Try our new interface for solving problems
Problems

Sum of digits

Sum of digits

n integers are given. Find among them the number with minimal sum of digits (in the case if there are some of them with the same sum – print the last number from the input sequence).

Input

First line contains n (1n105). Next line contains n positive integers. Each number is not greater than 109.

Output

Print the number with minimal sum of digits.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4
7 8 9 10
Output example #1
10
Input example #2
4
41 32 23 14
Output example #2
14