#C12411. Sum of Digits of the Largest Number

    ID: 41836 Type: Default 1000ms 256MiB

Sum of Digits of the Largest Number

Sum of Digits of the Largest Number

Given a list of integers, your task is to determine the largest number in the list and then compute the sum of its digits. If the list is empty, output 0.

Note that the list may contain a single element or several elements. The input list is provided in two lines: the first line contains an integer n which represents the number of integers in the list, and the second line contains n space-separated integers.

If the list is empty (i.e. when n = 0), simply output 0.

Formula: If the largest number is L, then the answer is \(\sum_{d \in \text{digits}(L)} d\).

inputFormat

The first line of input contains a single integer n (0 ≤ n ≤ 105), which indicates the number of integers. The second line contains n space-separated integers. If n is 0, the list is considered empty.

outputFormat

Print a single integer representing the sum of the digits of the largest number in the list. If the list is empty, print 0.

## sample
0
0