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 x[2010], y[2010];
set<pair<long long, long long> > ln;
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<long long, long long> > p;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> x[i] >> y[i];
    p.push_back(make_pair(x[i] * n * 2, y[i] * n * 2));
  }
  sort(p.begin(), p.end());
  long long sx = 0;
  long long sy = 0;
  for (int i = 0; i < (int)(n); ++i) {
    sx += x[i] * 2;
    sy += y[i] * 2;
  }
  int ind = -1;
  for (int i = 0; i < (int)(n); ++i) {
    if (sx * 2 != p[i].first + p[n - i - 1].first ||
        sy * 2 != p[i].second + p[n - i - 1].second) {
      if (p[i] < make_pair(sx * 2 - p[n - i - 1].first,
                           sy * 2 - p[n - i - 1].second)) {
        ind = i;
      } else {
        ind = n - i - 1;
      }
      break;
    }
  }
  if (ind == -1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(n); ++i) {
    long long mx = (p[ind].first + p[i].first) / 2;
    long long my = (p[ind].second + p[i].second) / 2;
    mx -= sx;
    my -= sy;
    vector<long long> res(n);
    for (int j = 0; j < (int)(n); ++j) {
      res[j] = x[j] * my - y[j] * mx;
    }
    sort(res.begin(), res.end());
    bool good = true;
    long long sum = res[0] + res.back();
    for (int j = 0; j < (int)(n); ++j) {
      if (res[j] + res[n - j - 1] != sum) {
        good = false;
      }
    }
    if (!good) {
      continue;
    }
    if (mx < 0 || (mx == 0 && my < 0)) {
      mx = -mx;
      my = -my;
    }
    long long d = gcd(abs(mx), abs(my));
    mx /= d;
    my /= d;
    ln.insert(make_pair(mx, my));
  }
  cout << ln.size() << endl;
  return 0;
}
