Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/markaziy-simmetrik

Centrally symmetric?

Medium 1000 ms 128 MB 58%
Share

$n$ points are given on the plane (some may coincide). Is there a point $O$ on the plane such that rotating the set by $180^{\circ}$ around $O$ maps it onto itself (every point lands on a point of the set, and the multiplicities of coinciding points are preserved)? The coordinates of $O$ need not be integers. If so, print YES, otherwise print NO.

A set of points and the centre of symmetry; each point is joined through the centre to its pair

Input

The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.

Output

YES or NO.

Note

$1 \le n \le 10^{5}$
$-10^{9} \le x_{i}, y_{i} \le 10^{9}$

Examples

Input #1
5
0 0
2 1
-2 -1
3 -2
-3 2
Output #1
YES
Input #2
3
0 0
1 0
0 1
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.