Jacob had a terrible nightmare! In his dream, a city with
An example of a stable position is below:
Constraints
Input Specification
The first line contains a single integer
The second line contains
Output Specification
Output a single integer, the capacity of the city.
Sample Input
8
6 2 3 1 8 4 5 7
Sample Output
17
Explanation for Sample
The input corresponds to the image in the example configuration.
The
The
The
The
The
Comments