#C13934. Sum of Two Largest Numbers
Sum of Two Largest Numbers
Sum of Two Largest Numbers
Given an array of integers, your task is to compute the sum of the two largest integers in the array. The array will be provided as input from standard input and it is guaranteed that the array contains at least two numbers.
Note: You are not allowed to use built-in sorting functions. You should compute the two largest elements by iterating through the array only once.
The mathematical formulation is: If \(a_1, a_2, \dots, a_n\) are the integers of the input array, then find two numbers \(M_1\) and \(M_2\) such that \(M_1 \ge M_2\) and the answer is \(M_1+M_2\).
inputFormat
The first line of input contains a single integer \(n\) (\(n \ge 2\)), representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer, which is the sum of the two largest numbers in the array, printed to standard output.
## sample5
1 2 3 4 5
9