Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/raqam-yigindisi-eng-katta-son

Number with the largest digit sum

Easy 1000 ms 64 MB 31%
Share

$n$ positive integers are given. Print the one whose sum of digits is the largest. If there are several such numbers, print the first one in the list.

Numbers and their digit sums; the largest is highlighted

Input

The first line contains a positive integer $n$.
The second line contains $n$ positive integers.

Output

One positive integer.

Note

$1 \le n \le 10^{4}$
each number is from $1$ to $10^{9}$

Examples

Input #1
4
123 99 1000 45
Output #1
99
Input #2
3
18 81 9
Output #2
18

Sign in to submit a solution

Signing up is free and takes a minute.