Animal Farm


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

While Tom wasn't looking, the various farm animals in his field formed a caste system, separating into two classes who absolutely hate each other and blame each other for all of their misfortunes. Unfortunately, Tom needs to move them into a new pen and he has already laid out the convex fenced perimeter of the new pen. Before he undoes all of his hard work, he wants to verify if the pen is suitable or not first.

The two classes of animals cannot be mixed together since they despite each other, though the one thing that does unite them is socialism. Thus, for the animals to live in harmony, the pen must be divided into two sections of equal area by one additional line of fence connecting two of the perimeter fence posts. If it is impossible to divide the existing pen as such, then Tom must seek another solution before the working class of animals unite to overthrow the farm management...

Input

The first line contains a single integer n (4 \leq n \leq 10^5), the number of fence posts which form the vertices of the pen. The posts are labelled 1 through n.

The next n lines each contain two space-separated integers x_i and y_i (-10^6\leq x_i, y_i \leq 10^6), the coordinates of the ith fence post. The ith fence post is also connected via fence to the i+1th post, except for the final nth post which is connected to the 1st post, such that the fence forms a loop enclosing a simple polygon. This means that all the fences are straight lines, and they will never cross over or intersect each other. Moreover, the polygon is guaranteed to be convex. This means that any line drawn between two points in the polygon cannot go outside of the polygon, so there are no 'dents'.

Output

If the fenced pen can be divided into two sections of equal area using a straight line between two of the existing fence posts, output 'Yes', otherwise output 'No'.

Example

Input 1
4
0 0
0 1
1 1
1 0
Output 1
Yes

This shape is a simple 1 \times 1 square. Dividing across either of the diagonals would lead to equally-sized areas.

Input 2
5
0 0
0 1
1 2
2 1
2 0
Output 2
No

This shape is an irregular pentagon. There is no way to divide it into two sections of equal area.

Input 3
5
2 0
0 4
-2 0
-2 -2
2 -2
Output 3
Yes

We can draw a line between (-2, 0) and (2,0), dividing the polygon into an isosceles triangle and a rectangle. It can be seen that the rectangle and triangle have the same area. This is illustrated below:


Comments

There are no comments at the moment.