atcoder#ABC263D. [ABC263D] Left Right Operation
[ABC263D] Left Right Operation
Score : points
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.
5 4 3
5 5 0 6 3
14
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
4 10 10
1 2 3 4
10
If you choose and , you will get , for the sum of , which is the minimum sum achievable.
10 -5 -3
9 -6 10 -1 2 10 -1 7 -15 5
-58
, , and may be negative.