#K91387. Maximum Pairwise Sum

    ID: 37964 Type: Default 1000ms 256MiB

Maximum Pairwise Sum

Maximum Pairwise Sum

Given an array of integers, your task is to compute the maximum pairwise sum of two different elements. In other words, you need to pick two distinct indices i and j from the array and calculate the sum a_i + a_j. Mathematically, the solution is given by:

$$\max_{i \neq j}\{a_i + a_j\}$$

The array will be provided via standard input with the first line containing an integer n which denotes the number of elements, followed by a line of n space-separated integers.

inputFormat

The first line of input contains an integer n ($n \geq 2$) — the number of elements in the array. The second line contains n space-separated integers which represent the elements of the array.

outputFormat

Output a single integer, the maximum pairwise sum achievable by adding two distinct elements from the array.

## sample
5
1 2 3 4 5
9