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;
long long modu = (1LL << 31) - 1;
long long modu2 = (1LL << 62) - 1;
long long gcd(long long a, long long b) {
  for (; b;) {
    a %= b;
    swap(a, b);
  }
  return a;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second < b.second;
}
long long x[2000], y[2000], _x[2000], _y[2000];
bool exs[2000];
vector<pair<long long, long long>> K;
vector<long long> dst;
int main() {
  int n, i, j;
  scanf("%d", &n);
  long long cx = 0, cy = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld%lld", x + i, y + i);
    cx += x[i], cy += y[i];
    _x[i] = x[i], _y[i] = y[i];
    x[i] *= n, y[i] *= n;
  }
  for (i = 0; i < n; i++) {
    x[i] -= cx, y[i] -= cy;
    exs[i] = x[i] || y[i];
  }
  for (i = 0; i < n; i++) {
    if (!exs[i]) continue;
    for (j = i + 1; j < n; j++) {
      if (!exs[j]) continue;
      if (x[i] == -x[j] && y[i] == -y[j]) {
        exs[i] = exs[j] = 0;
        break;
      }
    }
  }
  for (i = 0, j = 0; i < n; i++) {
    if (exs[i]) {
      x[j] = x[i];
      y[j] = y[i];
      _x[j] = _x[i];
      _y[j] = _y[i];
      j++;
    }
  }
  n = j;
  if (n == 0) {
    printf("-1\n");
    return 0;
  }
  long long m2x, m2y, ex, ey, dc2;
  pair<long long, long long> dc;
  bool suc;
  K.clear();
  for (i = 0; i < n; i++) {
    m2x = x[0] + x[i];
    m2y = y[0] + y[i];
    ey = -m2x;
    ex = m2y;
    dst.clear();
    for (j = 0; j < n; j++) {
      dst.push_back(_x[j] * ex + _y[j] * ey);
    }
    sort(dst.begin(), dst.end());
    dc2 = dst.front() + dst.back();
    suc = true;
    for (j = 0; j <= (n - 1) / 2; j++) {
      if (dst[j] + dst[n - 1 - j] != dc2) {
        suc = false;
        break;
      }
    }
    if (suc) {
      long long d = gcd(ex, ey);
      ex /= d, ey /= d;
      if (ey < 0)
        ey = -ey, ex = -ex;
      else if (ey == 0 && ex < 0)
        ex = -ex;
      K.push_back(make_pair(ey, ex));
    }
  }
  sort(K.begin(), K.end(), cmp);
  for (i = 0; i < K.size(); i++) exs[i] = 1;
  for (i = 0, j = 0; i < K.size(); i++) {
    if (!i || K[i] != K[i - 1]) j++;
  }
  printf("%d\n", j);
  return 0;
}
