Light ray polygon
InterviewTime limit1sMemory limit1024 MB
Given the angles of incidence at mirrors A_1 to A_n of a convex polygon, the task is to find the angle at the laser pointer A_0.
Problem
Chang-yeon drew a picture with light rays by placing mirrors and a very small laser pointer on a plane.

An example of a picture drawn with light rays
The finished drawing forms a convex polygon . is the point where the laser pointer is located. The ray reflects off the mirrors at in order and returns to , where the laser pointer blocks it so it goes no further.

A ray reflecting off mirrors as it travels
The ray moves as follows. For convenience, let .
- The ray travels in a straight line from toward , reflects at , and then travels in a straight line toward .
- The angle of incidence at is , as shown in the figure.
Given the angles of incidence measured at the moment of reflection at each point , find in the figure. All angles in the problem use degrees, where a full turn is .
Input
The first line contains an integer .
The second line contains integers separated by spaces.
Output
Print an integer equal to the size of .
Constraints
- .
- .
- All interior angles of the convex polygon drawn on the plane are integers, and each is guaranteed to be at least and at most .