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.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(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, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            Point[] p = new Point[n];
            long sx = 0;
            long sy = 0;
            for (int i = 0; i < n; i++) {
                long x = in.nextLong();
                long y = in.nextLong();
                x *= n;
                y *= n;
                p[i] = new Point(x, y);
                sx += x;
                sy += y;
            }
            sx /= n;
            sy /= n;
            for (int i = 0; i < n; i++) {
                p[i].x -= sx;
                p[i].y -= sy;
            }
            p = removeSymmetrical(p);
            n = p.length;

            if (n <= 1) {
                out.println(-1);
                return;
            }

            Set<Point> ans = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                Point dir = p[0].add(p[i]).rotate90();
                if (dir.x == 0 && dir.y == 0) {
                    continue;
                }
                dir.normalizeDirection();
                long[] xs = new long[n];
                for (int j = 0; j < n; j++) {
                    xs[j] = dot(dir, p[j]);
                }
                Arrays.sort(xs);

                boolean ok = true;
                for (int j = 0; j < n; j++) {
                    if (xs[0] + xs[n - 1] != xs[j] + xs[n - 1 - j]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    ans.add(dir);
                }
            }
            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;
                    }
                }
            }

            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 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;
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

