Problem: 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

Solution (in JAVA):

Solution:

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class D2
{
	static PrintWriter out = new PrintWriter(
			new BufferedOutputStream(System.out));
	static MyScanner sc = new MyScanner(System.in);
	static StringBuilder output = new StringBuilder();
	static int m;
	static int n;
	static int[] a;
	static final int TRIES = 2;
	static boolean flip;

	public static void main(String... args)
	{
		m = sc.nextInt();
		n = sc.nextInt();
		flip = false;
		
		if (m == n)
		{
			output.append(0 + " " + 1);
			eOP();
		}
		
		a = new int[n];
		
		for (int i = 0; i < n; i++)
		{
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		if (n * 2 > m)
		{
			a = compliment(a);
			n = m - n;
			flip = true;
		}
		
		if (n == 1)
		{
			if (flip)
			{
				output.append(mod(a[0] + 1) + " " + 1);
				eOP();
			}
			else
			{
				output.append(a[0] + " " + 1);
				eOP();
			}
		}
		
		int[][] ds = new int[TRIES][n - 1];
		
		for (int i = 1; i < n; i++)
		{
			int d = minAbsDifference(a[0], a[i]);
			ds[0][i - 1] = d;
		}
		
		Arrays.sort(ds[0]);
		
		int d = -1;
		for (int i = 0; i < n - 1; i++)
		{
			if (ds[0][i] == d)
			{
				continue;
			}
			d = ds[0][i];
			
			int first = check(d);
			if (first != -1)
			{
				output.append(first + " " + d);
				eOP();
			}
		}
		
		output.append(-1);

		eOP();
	}
	
	private static int[] compliment(int[] a)
	{
		int[] result = new int[m - n];
		int i = 0;
		int j = 0;
		int v = 0;
		
		mainLoop:
		for (; v < m; i++, v++)
		{
			while (v == a[j])
			{
				j++;
				v++;
				if (v >= m)
				{
					return result;
				}
				if (j == a.length)
				{
					break mainLoop;
				}
			}
			result[i] = v;
		}
		for (;v < m; i++, v++)
		{
			result[i] = v;
		}
		
		return result;
	}

	private static int check(int d)
	{
		int inSequence = 1;
		int current = a[0];
		int first = -1;
		int last = -1;
		
		while(true)
		{
			current = mod(current - d);
			int pos = Arrays.binarySearch(a, current);
			if (pos >= 0)
			{
				inSequence++;
			}
			else
			{
				first = mod(current + d);
				break;
			}
		}
		
		current = a[0];
		while(true)
		{
			current = mod(current + d);
			int pos = Arrays.binarySearch(a, current);
			if (pos >= 0)
			{
				inSequence++;
			}
			else
			{
				last = mod(current - d);
				break;
			}
		}
		
		if (inSequence == n)
		{
			if (flip)
			{
				return mod(last + d);
			}
			return first;
		}
		else
		{
			return -1;
		}
	}

	private static int mod(int num)
	{
		num %= m;
		if (num < 0)
		{
			num += m;
		}
		
		return num;
	}

	private static int minAbsDifference(int a, int b)
	{
		int diff = a - b;
		int diff2 = -diff;
		
		diff = mod(diff);
		diff2 = mod(diff2);
		
		return Math.min(diff, diff2);
	}

	private static void eOP()
	{
		System.out.println(output);
		System.exit(0);
	}
	
	/**
	 * Flatfoot's Scanner with slight modifications.
	 * 
	 * @author <a href="http://codeforces.com/profile/Flatfoot">Flatfoot</a>
	 * @see <a href="http://codeforces.com/blog/entry/7018">Source</a>
	 */
	private static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream in)
		{
			this.br = new BufferedReader(new InputStreamReader(in));
		}

		String next()
		{
			while (this.st == null || !this.st.hasMoreElements())
			{
				try
				{
					this.st = new StringTokenizer(this.br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return this.st.nextToken();
		}

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

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

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

		/**
		 * This method has been modified to be a bit more similar to Scanner's
		 * 
		 * @author <a href=
		 *         "http://codeforces.com/profile/Flatfoot">Flatfoot</a>,
		 *         <a href=
		 *         "http://codeforces.com/profile/JasonBaby">JasonBaby</a>
		 */
		String nextLine()
		{
			if (this.st == null || !this.st.hasMoreElements())
			{
				String str = "";
				try
				{
					str = this.br.readLine();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
				return str;
			}
			else
			{
				StringBuilder str = new StringBuilder();
				while (this.st.hasMoreElements())
				{
					str.append(this.st.nextToken());
					str.append(" ");
				}
				str.deleteCharAt(str.length() - 1);
				return str.toString();
			}
		}

	}
}