You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.

Multiset is a set where equal elements are allowed.

Multiset is called symmetric, if there is a point P on the plane such that the multiset is [centrally symmetric](https://en.wikipedia.org/wiki/Point_reflection) in respect of point P.

Input

The first line contains a single integer n (1 ≤ n ≤ 2000) — the number of points in the set.

Each of the next n lines contains two integers xi and yi ( - 106 ≤ xi, yi ≤ 106) — the coordinates of the points. It is guaranteed that no two points coincide.

Output

If there are infinitely many good lines, print -1.

Otherwise, print single integer — the number of good lines.

Examples

Input

3
1 2
2 1
3 3


Output

3


Input

2
4 3
1 2


Output

-1

Note

Picture to the first sample test:

<image>

In the second sample, any line containing the origin is good.
#include <bits/stdc++.h>
using namespace std;
struct dot {
  int x, y;
  dot(int _x = 0, int _y = 0) { x = _x, y = _y; }
  void read() { scanf("%d %d", &x, &y); }
} a[2010], l[2010 * 2010];
int n, t;
long long mo[2010];
dot operator-(dot a, dot b) { return dot(a.x - b.x, a.y - b.y); }
dot operator+(dot a, dot b) { return dot(a.x + b.x, a.y + b.y); }
dot operator*(dot a, int k) { return dot(a.x * k, a.y * k); }
long long dtime(dot a, dot b) { return 1ll * a.x * b.x + 1ll * a.y * b.y; }
long long ctime(dot a, dot b) { return 1ll * a.x * b.y - 1ll * a.y * b.x; }
dot perpend(dot a) { return dot(a.y, -a.x); }
dot abs(dot a) {
  if (a.y < 0) a.y = -a.y, a.x = -a.x;
  if (a.y == 0 && a.x < 0) a.x = -a.x;
  return a;
}
bool cmp(dot a, dot b) { return ctime(a, b) > 0; }
int main() {
  dot core = dot(0, 0);
  scanf("%d", &n);
  t = 0;
  for (int i = 1, _E_ = n; i <= _E_; ++i)
    a[i].read(), core = core + a[i], a[i] = a[i] * n;
  for (int i = 1, _E_ = n; i <= _E_; ++i) a[i] = a[i] - core;
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j)
      if (a[i].x == -a[j].x && a[i].y == -a[j].y) {
        if (i == j) {
          swap(a[i], a[n]);
          n--;
        } else {
          if (j == n)
            swap(a[n - 1], a[i]);
          else
            swap(a[n], a[i]), swap(a[n - 1], a[j]);
          n -= 2;
        }
        j = i;
      }
  if (n <= 2) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1, _E_ = n; i <= _E_; ++i)
    for (int j = 1, _E_ = n; j <= _E_; ++j)
      if (a[i].x + a[j].x || a[i].y + a[j].y)
        l[++t] = abs(perpend(a[i] + a[j]));
  sort(l + 1, l + t + 1, cmp);
  int tot = 0;
  for (int i = 1, las = 0; i <= t; ++i)
    if (i == t || ctime(l[i], l[i + 1]) != 0) {
      if (i - las >= n + 1 >> 1) {
        for (int j = 1, _E_ = n; j <= _E_; ++j) mo[j] = dtime(a[j], l[i]);
        sort(mo + 1, mo + n + 1);
        int p = 1;
        for (int j = 1, _E_ = n; j <= _E_; ++j)
          if (mo[j] != -mo[n + 1 - j]) p = 0;
        if (p) ++tot;
      }
      las = i;
    }
  printf("%d\n", tot);
  return 0;
}
