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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
long long mod_pow(long long x, long long n, long long p) {
  long long res = 1;
  x %= p;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
long long mod_inv(long long x, long long p) { return mod_pow(x % p, p - 2, p); }
long long mod_sqrt(long long x, long long p) {
  x %= p;
  if (x == 0) return 0;
  if (p == 2) return x;
  auto is_square = [&](long long a) { return mod_pow(a, (p - 1) / 2, p) == 1; };
  if (!is_square(x)) return -1;
  long long y = 2;
  while (is_square((y * y - x + p) % p)) y++;
  long long r = (y * y - x + p) % p;
  auto mul = [&](pair<long long, long long> u, pair<long long, long long> v) {
    long long s = (u.first * v.first + u.second * v.second % p * r) % p;
    long long t = (u.second * v.first + u.first * v.second) % p;
    return make_pair((s), (t));
  };
  long long e = (p + 1) / 2;
  auto ret = make_pair((1LL), (0LL));
  auto v = make_pair((y), (1LL));
  while (e > 0) {
    if (e & 1) ret = mul(ret, v);
    v = mul(v, v);
    e /= 2;
  }
  assert(r == 0 || ret.second == 0);
  return ret.first;
}
int main() {
  long long m, n;
  cin >> m >> n;
  vector<long long> vec(n);
  for (int i = (int)(0); i < (int)(n); i++) scanf("%d", &vec[i]);
  set<long long> st;
  for (int i = (int)(0); i < (int)(n); i++) st.insert(vec[i]);
  if (n == 1) {
    cout << vec[0] << " " << 0;
    return 0;
  }
  if (m < n) {
    cout << -1 << endl;
    return 0;
  }
  if (m == n) {
    cout << vec[0] << " " << 1 << endl;
    return 0;
  }
  if (n == m - 1) {
    for (int i = (int)(0); i < (int)(m); i++)
      if (st.find(i) == st.end()) {
        cout << (i + 1) % m << " " << 1 << endl;
        return 0;
      }
  }
  long long s = accumulate((vec).begin(), (vec).end(), 0LL);
  long long avg = s % m * mod_inv(n, m) % m;
  long long v = 0;
  for (int i = (int)(0); i < (int)(n); i++)
    v += (vec[i] - avg) * (vec[i] - avg) % m;
  v = v % m * mod_inv(n, m) % m;
  long long d = mod_sqrt(12 * v % m * mod_inv(n * n - 1, m) % m, m);
  if (d <= 0) {
    cout << -1 << endl;
    return 0;
  }
  int tmp = vec[0];
  int cnt = 1;
  while (cnt < n && st.find((tmp + d) % m) != st.end()) {
    tmp = (tmp + d) % m;
    cnt++;
  }
  tmp = vec[0];
  while (cnt < n && st.find((tmp - d + m) % m) != st.end()) {
    tmp = (tmp - d + m) % m;
    cnt++;
  }
  if (cnt == n) {
    cout << tmp << " " << d << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}