Angles of Overlapping Polygons
Time limit1sMemory limit1024 MB
Given nested convex polygons with non-increasing vertex counts A_i, find the maximum sum of counted angles in a valid figure.
Problem
You must draw a figure made of convex polygons. The figure must satisfy the following three conditions.
- The -th polygon has vertices. ()
- Every vertex of the -th polygon lies inside or on the boundary of the -th polygon. ()
- No two or more polygons may share a vertex.
The -th polygon has at least as many vertices as the -th polygon. That is, for every integer with .
The figure below shows a valid and an invalid drawing when .
You want the score of the figure to be as large as possible. The score is the sum of the angles, each less than , formed by the line segments drawn in the figure, counting only those angles that do not fully contain another angle.

For example, and in the figure above are valid. is not valid, because it contains both and .
Find the maximum score that a valid figure can have.
Input
The first line contains the number of polygons .
The second line contains integers separated by spaces.
Output
Print the maximum score of a valid figure on the first line.

