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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Point[] p = new Point[n];
            Point cen = new Point(0, 0);
            for (int i = 0; i < n; i++) {
                long x = in.nextLong();
                long y = in.nextLong();
                p[i] = new Point(x, y);
                cen = cen.add(p[i]);
                p[i] = p[i].mul(n);
            }
            for (int i = 0; i < n; ++i) {
                p[i] = p[i].minus(cen);
            }
            p = removeSymmetrical(p);
            n = p.length;
            if (n == 0) {
                out.println("-1");
                return;
            }
            Set<Point> ans = new TreeSet<>();
            for (int i = 0; i < n; ++i) {
                Point a = p[0], b = p[i];
                Point vec = a.add(b).rotate90();
                vec.normalizeDirection();
                long[] d = new long[n];
                for (int j = 0; j < n; ++j)
                    d[j] = dot(p[j], vec);

                Arrays.sort(d);
                boolean ok = true;
                for (int j = 0; j < n; ++j) {
                    if (d[j] + d[n - j - 1] != 0) {
                        ok = false;
                        break;
                    }
                }
                if (ok) ans.add(vec);
            }
            out.println(ans.size());
        }

        private Point[] removeSymmetrical(Point[] p) {
            int n = p.length;
            boolean[] dead = new boolean[n];
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (!dead[i] && !dead[j] && p[i].x == -p[j].x && p[i].y == -p[j].y) {
                        dead[i] = true;
                        dead[j] = true;
                    }
                }
            }
            for (int i = 0; i < n; ++i) {
                if (p[i].x == 0 && p[i].y == 0)
                    dead[i] = true;
            }
            int k = 0;
            for (int i = 0; i < n; i++) {
                if (!dead[i]) {
                    p[k++] = p[i];
                }
            }
            return Arrays.copyOf(p, k);
        }

        private long dot(Point a, Point b) {
            return a.x * b.x + a.y * b.y;
        }

        private long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        class Point implements Comparable<Point> {
            long x;
            long y;

            Point(long x, long y) {
                this.x = x;
                this.y = y;
            }

            Point add(Point o) {
                return new Point(x + o.x, y + o.y);
            }

            Point minus(Point o) {
                return new Point(x - o.x, y - o.y);
            }

            Point mul(long n) {
                return new Point(x * n, y * n);
            }

            Point rotate90() {
                return new Point(-y, x);
            }

            void normalizeDirection() {
                long d = gcd(Math.abs(x), Math.abs(y));
                if (y > 0 || y == 0 && x > 0) {

                } else {
                    x = -x;
                    y = -y;
                }
                if (d != 0) {
                    x /= d;
                    y /= d;
                }
            }

            public int compareTo(Point o) {
                if (x != o.x) {
                    return x < o.x ? -1 : 1;
                }
                if (y != o.y) {
                    return y < o.y ? -1 : 1;
                }
                return 0;
            }

        }

    }
}

