#K49837. Maximum Importance Sum After At Most One Swap

    ID: 28731 Type: Default 1000ms 256MiB

Maximum Importance Sum After At Most One Swap

Maximum Importance Sum After At Most One Swap

You are given n paintings where each painting has an associated importance value. You are allowed to perform at most one swap operation between any two paintings. After the (optional) swap, the overall importance sum is defined as the sum of all the paintings' importance values.

Note that swapping does not change the total sum. Therefore, the maximum possible sum is simply the sum of the given importance values.

In mathematical terms, if the importance values are (a_1, a_2, \dots, a_n), the answer is (\sum_{i=1}^{n}a_i).

inputFormat

The first line contains a single integer n (1 ≤ n ≤ 10^5) – the number of paintings. The second line contains n space-separated integers representing the importance values of the paintings.

outputFormat

Output a single integer – the maximum possible sum of the importance values after performing at most one swap operation.## sample

1
5
5