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 gcd(long long x, long long y) { return (y == 0 ? x : gcd(y, x % y)); }
set<pair<long long, long long> > setik;
const int N = 2020;
pair<long long, long long> a[N];
int n;
pair<long long, long long> C;
pair<long long, long long> b[N];
long long p[N];
bool solve(long long x, long long y) {
  for (int i = 0; i < n; i++) p[i] = a[i].first * x + a[i].second * y;
  sort(p, p + n);
  long long S = p[0] + p[n - 1];
  for (int i = 0; i < n; i++)
    if (p[i] + p[n - 1 - i] != S) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  C = make_pair(0LL, 0LL);
  for (int i = 0; i < n; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    C.first += x;
    C.second += y;
    x *= 2 * n;
    y *= 2 * n;
    a[i] = make_pair(x, y);
    setik.insert(a[i]);
  }
  C.first *= 2;
  C.second *= 2;
  while (!setik.empty()) {
    pair<long long, long long> t = *setik.begin();
    if (t == C) {
      setik.erase(setik.begin());
      continue;
    }
    pair<long long, long long> t2 =
        make_pair(2 * C.first - t.first, 2 * C.second - t.second);
    if (setik.count(t2) != 0) {
      setik.erase(t);
      setik.erase(t2);
      continue;
    }
    break;
  }
  if (setik.empty()) {
    printf("-1\n");
    return 0;
  }
  int m = 0;
  pair<long long, long long> t1 = *setik.begin();
  for (auto t2 : setik) {
    b[m++] = make_pair((t1.first + t2.first) / 2 - C.first,
                       (t1.second + t2.second) / 2 - C.second);
  }
  for (int i = 0; i < m; i++) {
    if (b[i].first < 0 || (b[i].first == 0 && b[i].second < 0)) {
      b[i].first *= -1;
      b[i].second *= -1;
    }
    long long g = gcd(abs(b[i].first), abs(b[i].second));
    b[i].first /= g;
    b[i].second /= g;
  }
  sort(b, b + m);
  m = unique(b, b + m) - b;
  int ans = 0;
  for (int i = 0; i < m; i++)
    if (solve(-b[i].second, b[i].first)) ans++;
  printf("%d\n", ans);
  return 0;
}
