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;
const int N = 2e3 + 9;
bool used[N];
struct Point {
  long long x, y;
  Point operator+(const Point& b) const { return (Point){x + b.x, y + b.y}; }
  Point operator/(const long long& b) const { return (Point){x / b, y / b}; }
  Point operator*(const long long& b) const { return (Point){x * b, y * b}; }
  Point rotate() { return (Point){-y, x}; }
  bool operator<(const Point& b) const {
    if (x == b.x) return y < b.y;
    return x < b.x;
  }
  bool operator==(const Point& b) const { return x == b.x && y == b.y; }
  long long dot(const Point& b) const { return x * b.x + y * b.y; }
} pt[N], p0;
int n;
vector<Point> p;
map<long long, int> mp;
map<double, int> line_vis;
void pre_solve() {
  for (int i = 1; i <= n; ++i) {
    if (used[i]) continue;
    for (int j = i + 1; j <= n; ++j) {
      if (used[j]) continue;
      Point tp = (pt[i] + pt[j]);
      if (tp == p0 * 2) {
        used[i] = used[j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (used[i]) continue;
    p.push_back(pt[i]);
  }
}
bool judge(Point line) {
  mp.clear();
  long long p0_d = p0.dot(line);
  for (auto v : p) {
    long long d = v.dot(line);
    d -= p0_d;
    mp[d]++;
  }
  for (auto it : mp) {
    long long val = it.first;
    int num = it.second;
    if (val == 0) continue;
    if (mp[-val] != num) return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %lld", &pt[i].x, &pt[i].y);
    pt[i] = pt[i] * n;
    p0 = p0 + pt[i];
  }
  if (n <= 2) {
    puts("-1");
    return 0;
  }
  p0 = p0 / n;
  pre_solve();
  if (p.size() == 0) {
    puts("-1");
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < p.size(); ++i) {
    double tx = (p[0].x + p[i].x) * 0.5;
    double ty = (p[0].y + p[i].y) * 0.5;
    tx = p0.x - tx;
    ty = p0.y - ty;
    long long temx = 2 * tx, temy = 2 * ty;
    if (temy < 0 || (temy == 0 && temx < 0)) {
      temx = -temx;
      temy = -temy;
    }
    Point vec = (Point){temx, temy};
    double the = atan2(temy, temx);
    if (line_vis[the]) continue;
    line_vis[the] = 1;
    vec = vec.rotate();
    if (judge(vec)) {
      ++ans;
    }
  }
  printf("%d", ans);
  return 0;
}
