#abc263d. [abc263_d]Left Right Operation
[abc263_d]Left Right Operation
Problem Statement
You are given an integer sequence of length : .
You will perform the following consecutive operations just once:
-
Choose an integer . If is , do nothing. If is or greater, replace each of with .
-
Choose an integer . If is , do nothing. If is or greater, replace each of with .
Print the minimum possible sum of the elements of after the operations.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5 4 3
5 5 0 6 3
Sample Output 1
14
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
Sample Input 2
4 10 10
1 2 3 4
Sample Output 2
10
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
Sample Input 3
10 -5 -3
9 -6 10 -1 2 10 -1 7 -15 5
Sample Output 3
-58
, , and may be negative.