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;
int t, n, ct, vis[2010], ha, r, c1;
double x[2010], y[2010], c[2010], d[2010], a, b, l[2010 * 2010], va[2010],
    pt[2010];
int pd(double x, double y) { return fabs(x - y) < 1e-7; }
void init() {
  ct = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (pd((x[i] + x[j]), a * 2.0) && pd((y[i] + y[j]), b * 2.0))
        vis[i] = vis[j] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      c[++ct] = x[i];
      d[ct] = y[i];
    }
  if (ct < 2) ha = 0;
}
void cans(double va) {
  double bz = b - va * a;
  for (int i = 1; i <= ct; i++) pt[i] = d[i] - va * c[i];
  sort(pt + 1, pt + ct + 1);
  for (int i = 1; i <= ct / 2; i++)
    if (!pd(pt[i] + pt[ct - i + 1], 2 * bz)) return;
  r++;
}
void doit() {
  c1 = 0;
  for (int i = 1; i <= ct; i++)
    for (int j = i + 1; j <= ct; j++)
      if (!pd(2.0 * a - c[i] - c[j], 0))
        l[++c1] = (2.0 * b - d[i] - d[j]) / (2.0 * a - c[i] - c[j]);
  sort(l + 1, l + c1 + 1);
  int w = 1;
  for (int i = 2; i <= c1; i++) {
    if (!pd(l[i], l[i - 1])) {
      if (w >= ct / 2) cans(l[i - 1]);
      w = 1;
    } else
      w++;
  }
  if (w >= ct / 2) cans(l[c1]);
  for (int i = 1; i <= ct; i++) pt[i] = c[i];
  sort(pt + 1, pt + ct + 1);
  int ok = 1;
  for (int i = 1; i <= ct / 2; i++)
    if (!pd(pt[i] + pt[ct - i + 1], a * 2.0)) ok = 0;
  r += ok;
}
int main() {
  ha = 1;
  r = 0;
  a = b = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf%lf", &x[i], &y[i]);
    a += x[i];
    b += y[i];
  }
  a /= (double)n;
  b /= (double)n;
  init();
  if (!ha) {
    printf("-1\n");
    return 0;
  }
  doit();
  printf("%d\n", r);
}
