Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere.

One of his birthday presents was a sequence of distinct integers a1, a2, ..., an. Timofey wants to know whether he can rearrange the elements of the sequence so that is will be an arithmetical progression modulo m, or not.

Arithmetical progression modulo m of length n with first element x and difference d is sequence of integers x, x + d, x + 2d, ..., x + (n - 1)·d, each taken modulo m.

Input

The first line contains two integers m and n (2 ≤ m ≤ 109 + 7, 1 ≤ n ≤ 105, m is prime) — Timofey's favorite prime module and the length of the sequence.

The second line contains n distinct integers a1, a2, ..., an (0 ≤ ai < m) — the elements of the sequence.

Output

Print -1 if it is not possible to rearrange the elements of the sequence so that is will be an arithmetical progression modulo m.

Otherwise, print two integers — the first element of the obtained progression x (0 ≤ x < m) and its difference d (0 ≤ d < m).

If there are multiple answers, print any of them.

Examples

Input

17 5
0 2 4 13 15


Output

13 2


Input

17 5
0 2 4 13 14


Output

-1


Input

5 3
1 2 3


Output

3 4
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;
        int m;

        boolean in(int x, int[] a) {
            return Arrays.binarySearch(a, x) >= 0;
        }

        boolean check(int d, int[] a) {

            int n = a.length;

            int x = a[0];
            int cnt = 0;
            while (cnt < n && in(x, a)) {
                cnt++;
                x = Mod.addMod(x, d, m);
            }

            if (cnt >= n) {
                return true;
            } else {
                int rem = n - cnt;
                if (!in(Mod.subMod(a[0], Mod.mulMod(rem, d, m), m), a)) return false;
            }

            x = Mod.subMod(a[0], d, m);
            while (cnt < n && in(x, a)) {
                cnt++;
                x = Mod.subMod(x, d, m);
            }
            return cnt >= n;
        }

        int getd(int a, int b) {
            return (b + m - a) % m;
        }

        void output(int d, PrintWriter out) {
            int x = a[0];
            int cnt = 0;
            int save = x;
            while (cnt < n && in(x, a)) {
                save = x;
                cnt++;
                x = Mod.subMod(x, d, m);
            }
            out.println(save + " " + d);
        }

        int calc(int[] a) {
            int n = a.length;
            if (n == 1) {
                return 1;
            }

            for (int i = 1; i < n; ++i) {
                int d = getd(a[0], a[i]);
                if (check(d, a)) {
                    return d;
                }

                d = getd(a[i], a[0]);
                if (check(d, a)) {
                    return d;
                }
            }

            return -1;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long start = System.currentTimeMillis();
            m = in.nextInt();
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            Arrays.sort(a);

            if (n == 1 || n == m) {
                out.println(a[0] + " " + 1);
                return;
            }

            if (m - n < n) {
                boolean[] black = new boolean[m];
                for (int i = 0; i < n; ++i) black[a[i]] = true;
                b = new int[m - n];
                int nb = 0;
                for (int i = 0; i < m; ++i)
                    if (!black[i]) {
                        b[nb++] = i;
                    }
                int d = calc(b);
                if (d == -1) {
                    out.println(-1);
                } else {

                    if (!check(d, a)) throw new RuntimeException();
                    output(d, out);

                }
            } else {
                int d = calc(a);
                if (d == -1) {
                    out.println(-1);
                } else {
                    output(d, out);
                }
            }

            System.err.println("Time " + (System.currentTimeMillis() - start));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class Mod {
        public static final boolean DEBUG = false;

        public static int addMod(int a, int b, long MOD) {
            if (DEBUG) return a + b;

            while (a < 0)
                a += MOD;
            while (b < 0)
                b += MOD;
            return (int) (((long) a + (long) b) % MOD);
        }

        public static int subMod(int a, int b, long MOD) {
            if (DEBUG) return a - b;

            while (a < 0)
                a += MOD;
            while (b < 0)
                b += MOD;
            long temp = (long) a - (long) b;

            while (temp < 0)
                temp += MOD;
            return (int) temp;
        }

        public static int mulMod(int a, int b, long MOD) {
            if (DEBUG) return a * b;

            while (a < 0)
                a += MOD;
            while (b < 0)
                b += MOD;
            return (int) (((long) a) * ((long) b) % MOD);
        }

    }
}

