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
#include <bits/stdc++.h>
using namespace std;
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const long long MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = {0, 1, 0, -1, 1, -1, -1, 1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long sqr(long long x) { return x * x; }
long long sqr(int x) { return (long long)x * x; }
double sqr(double x) { return x * x; }
long double sqr(long double x) { return x * x; }
mt19937 tw(179239);
int rnd(int x, int y) {
  static uniform_int_distribution<int> d;
  return d(tw) % (y - x + 1) + x;
}
const int N = 200179;
int mod, n;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &mod, &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  if (n == 1) {
    cout << a[0] << " " << 0 << "\n";
    return 0;
  }
  if (n == 2) {
    cout << a[0] << " " << (mod + a[1] - a[0]) % mod << "\n";
    return 0;
  }
  if (n == mod) {
    cout << "0 1\n";
    return 0;
  }
  bool swd = false;
  if (n + n > mod) {
    swd = true;
    static bool h[N];
    for (int i = 0; i < n; ++i) h[a[i]] = true;
    n = 0;
    for (int i = 0; i < mod; ++i)
      if (!h[i]) a[n++] = i;
    if (n == 1) {
      int ansX = a[0];
      int ansD = 1;
      ansX = (ansX - ansD + mod) % mod;
      ansD = (mod - ansD) % mod;
      cout << ansX << " " << ansD << "\n";
      return 0;
    }
    if (n == 2) {
      int ansX = a[0];
      int ansD = (a[1] + mod - a[0]) % mod;
      ansX = (ansX - ansD + mod) % mod;
      ansD = (mod - ansD) % mod;
      cout << ansX << " " << ansD << "\n";
      return 0;
    }
  } else
    sort(a, a + n);
  a[n] = IINF;
  map<int, int> ds;
  for (int i = 0; i < 200; ++i) {
    int ind = rnd(0, n - 1);
    int x = a[ind];
    int k1 = 0, k2 = 0;
    while (k1 < n && k2 < n) {
      int d1 = (a[ind + k1 >= n ? ind + k1 - n : ind + k1] - x);
      if (d1 < 0) d1 += mod;
      int d2 = (x - a[ind - k2 < 0 ? ind - k2 + n : ind - k2]);
      if (d2 < 0) d2 += mod;
      if (d1 < d2)
        ++k1;
      else if (d1 > d2)
        ++k2;
      else {
        ++ds[d1];
        ++k1;
        ++k2;
      }
    }
  }
  vector<pair<int, int> > dsc;
  for (auto pp : ds)
    if (pp.first != 0) dsc.emplace_back(pp.second, pp.first);
  sort(dsc.begin(), dsc.end(), greater<pair<int, int> >());
  int ansX = -1, ansD = -1;
  for (auto dd : dsc) {
    if (dd.first != dsc[0].first) {
      cout << "-1\n";
      return 0;
    }
    int d = dd.second;
    int cnt = 1;
    int x = a[0];
    while (true) {
      x += d;
      if (x >= mod) x -= mod;
      if (*lower_bound(a, a + n, x) != x) break;
      ++cnt;
    }
    x = a[0];
    while (true) {
      x -= d;
      if (x < 0) x += mod;
      if (*lower_bound(a, a + n, x) != x) break;
      ++cnt;
    }
    x += d;
    if (x >= mod) x -= mod;
    if (cnt == n) {
      ansD = d;
      ansX = x;
      break;
    }
  }
  if (ansX == -1) {
    cout << "-1\n";
    return 0;
  }
  if (swd) {
    ansX = (ansX - ansD + mod) % mod;
    ansD = (mod - ansD) % mod;
  }
  cout << ansX << " " << ansD << "\n";
  return 0;
}
