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.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		Scanner sc = new Scanner();
		//		try {
		//			PrintWriter pw = new PrintWriter(new File("out.txt"));
		//			long m = 1000000007;
		//			long n = 100000;
		//			pw.println(m);
		//			pw.println(n);
		//			for (int i = 0; i < n; ++i) {
		//				pw.println((x + i * d % m) % m);
		//			}
		//			pw.close();
		//		} catch (FileNotFoundException e) {
		//			// TODO 自動生成された catch ブロック
		//			e.printStackTrace();
		//		}
		long M = sc.nextLong();
		int N = sc.nextInt();
		long[] A = new long[N];
		long sum = 0;
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
			sum = (sum + A[i]) % M;
		}

		if (N == M) {
			System.out.println(0 + " " + 1);
			return;
		}
		if (N == 1) {
			System.out.println(A[0] + " " + 0);
			return;
		}
		if (N == M - 1) {
			Arrays.sort(A);
			for (int i = 0; i < N; ++i) {
				if (A[i] != i) {
					System.out.println(A[i] + " " + 1);
					return;
				}
			}
			throw new AssertionError();
		}
		if (M == 2 || M == 3) {
			for (int x = 0; x < M; ++x) {
				in: for (int d = 0; d < M; ++d) {
					long[] arr = new long[N];
					for (int k = 0; k < N; ++k) {
						arr[k] = (x + k * d) % M;
					}
					Arrays.sort(arr);
					for (int i = 0; i < N; ++i) {
						if (arr[i] != A[i])
							continue in;
					}
					System.out.println(x + " " + d);
					return;
				}
			}
			System.out.println(-1);
			return;
		}

		long ave = sum * inv(N, M) % M;
		long var = 0;
		for (int i = 0; i < N; ++i) {
			var = (var + ((A[i] - ave) % M) * ((A[i] - ave) % M) % M) % M;
		}
		var = var * inv(N, M) % M * inv(N - 1, M) % M * inv(N + 1, M) % M * 12 % M;
		if (pow(var, (M - 1) / 2, M) == M - 1) {
			System.out.println(-1);
			return;
		}
		var = calc(var, M);
		ave = (ave - inv(2, M) * (N - 1) % M * var % M + M) % M;
		long[] check = new long[N];
		for (int i = 0; i < N; ++i) {
			check[i] = (ave + i * var % M) % M;
		}
		Arrays.sort(check);
		Arrays.sort(A);
		for (int i = 0; i < N; ++i) {
			if (check[i] != A[i]) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(ave + " " + var);
	}

	long inv(long a, long M) {
		return pow(a, M - 2, M);
	}

	long pow(long a, long n, long M) {
		a %= M;
		long ret = 1;
		for (; n > 0; n >>= 1, a = a * a % M) {
			if (n % 2 == 1) {
				ret = ret * a % M;
			}
		}
		return ret;
	}

	long calc(long a, long p) {
		a %= p;
		if (a == 0)
			return 0;
		if (a == 1)
			return 1;
		long s = 0;
		long tmp = p - 1;
		while (tmp % 2 == 0) {
			++s;
			tmp /= 2;
		}
		long Q = tmp;
		long z = 1;
		while (pow(z, (p - 1) / 2, p) != p - 1) {
			++z;
		}
		long M = s;
		long c = pow(z, Q, p);
		long t = pow(a, Q, p);
		long R = pow(a, (Q + 1) / 2, p);
		while (t != 1) {
			long cur = t;
			int i;
			for (i = 1; i < M; ++i) {
				cur = cur * cur % p;
				if (cur == 1)
					break;
			}
			if (cur != 1) {
				throw new AssertionError();
			}
			long b = pow(c, pow(2, M - i - 1, p - 1), p);
			M = i;
			c = b * b % p;
			t = t * b % p * b % p;
			R = R * b % p;
		}
		if (R * R % p != a) {
			throw new AssertionError();
		}
		return R;
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
