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 = 2010;
int n, id[N], x;
struct point {
  double x, y;
  point operator+(point a) { return (point){x + a.x, y + a.y}; }
  point operator-(point a) { return (point){x - a.x, y - a.y}; }
  point operator/(double a) { return (point){x / a, y / a}; }
  bool operator==(point a) {
    return abs(x - a.x) < 1e-9 && abs(y - a.y) < 1e-9;
  }
  double operator*(point a) { return x * a.x + y * a.y; }
} p[N], root, mid, vec;
pair<double, int> P[N];
bool check(int pos) {
  mid = (p[x] + p[pos]) / 2;
  vec = root - mid;
  vec = (point){vec.y, -vec.x};
  for (int i = 1; i <= n; i++) P[i] = make_pair(vec * p[i], i);
  sort(P + 1, P + n + 1);
  for (int i = 1; i <= n; i++) id[P[i].second] = i;
  if (id[x] + id[pos] != n + 1) return 0;
  double flag = P[1].first + P[n].first;
  for (int i = 1; i <= n; i++)
    if (abs(P[i].first + P[n - i + 1].first - flag) > 1e-9) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf%lf", &p[i].x, &p[i].y);
    root = root + p[i];
  }
  root = root / n;
  bool inf = 1;
  for (int i = 1; i <= n; i++) {
    bool is = 0;
    for (int j = 1; j <= n; j++)
      if (p[i] + p[j] == root + root) is = 1;
    if (!is) inf = 0, x = i;
  }
  if (inf) return puts("-1"), 0;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (check(i)) ans++;
  cout << ans << endl;
  return 0;
}
