Score : 1000 points
There is a stack of N cards, each of which has a non-negative integer written on it. The integer written on the i-th card from the top is A_i.
Snuke will repeat the following operation until two cards remain:
Find the minimum possible sum of the integers written on the last two cards remaining.
Input is given from Standard Input in the following format:
N A_1 A_2 ... A_N
Print the minimum possible sum of the integers written on the last two cards remaining.
4 3 1 4 2
16
We can minimize the sum of the integers written on the last two cards remaining by doing as follows:
6 5 2 4 1 6 9
51
10 3 1 4 1 5 9 2 6 5 3
115