#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 6;
int mod;
long long mpow(int a, int b) {
  int ans = 1;
  for (int i = 1; i <= b; i <<= 1) {
    if (i & b) ans = ((long long)ans * a) % mod;
    a = ((long long)a * a) % mod;
  }
  return ans;
}
int a[N], b[N], c[2 * N];
set<int> x[2], pr;
int main() {
  int n;
  cin >> mod >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pr.insert(a[i]);
    sum += a[i];
    sum %= mod;
  }
  if (n == 1) {
    cout << a[1] << " " << 1 << endl;
    return 0;
  }
  if (n == mod) {
    cout << 1 << " " << 1 << endl;
    return 0;
  }
  int ind = 0;
  if (mod < 2 * N - 5) {
    for (int i = 1; i <= n; i++) {
      c[a[i]] = 1;
    }
    for (int i = 0; i < mod; i++) {
      if (!c[i]) {
        b[ind++] = i;
      }
    }
  }
  int inv = mpow(n, mod - 2);
  int invn = mpow(n - 1, mod - 2);
  int inv2 = mpow(2, mod - 2);
  for (int i = 1; i <= n; i++) {
    int xx = (sum * 2LL) % mod;
    xx = ((long long)xx * inv) % mod;
    xx = xx - 2LL * a[i] + mod;
    xx = ((long long)xx * invn) % mod;
    if (xx < 0) xx += mod;
    if (xx) x[0].insert(xx);
  }
  if (mod < 2 * N - 5 && ind > 0) {
    for (auto it : x[0]) {
      int flag = 1;
      int invd = mpow(it, mod - 2);
      int aa = (long long)((2 * sum) % mod) * inv % mod;
      aa -= (long long)(n - 1) * it % mod;
      aa = (long long)aa * inv2 % mod;
      if (aa < 0) aa += mod;
      for (int i = 1; i < 100; i++) {
        int xx = b[rand() % ind];
        int yy = (long long)(xx - aa) * invd % mod;
        if (yy < 0) yy += mod;
        if (yy < n) {
          flag = 0;
          break;
        }
      }
      if (flag) x[1].insert(it);
    }
  } else {
    for (auto it : x[0]) {
      x[1].insert(it);
    }
  }
  for (int i = 1; i <= 100; i++) {
    x[(i + 1) & 1].clear();
    int xx = rand() % n;
    xx++;
    for (int j = 1; j <= n; j++) {
      if (j == xx) continue;
      int t1 = a[xx] - a[j];
      int t2 = a[j] - a[xx];
      if (t1 < 0)
        t1 += mod;
      else
        t2 += mod;
      if (x[i & 1].count(t1)) x[(i + 1) & 1].insert(t1);
      if (x[i & 1].count(t2)) x[(i + 1) & 1].insert(t2);
    }
  }
  assert(x[1].size() < 100);
  for (auto it : x[1]) {
    int aa = (long long)((2 * sum) % mod) * inv % mod;
    aa -= (long long)(n - 1) * it % mod;
    aa = (long long)aa * inv2 % mod;
    if (aa < 0) aa += mod;
    int bb = aa;
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      if (!pr.count(aa)) {
        flag = 0;
        break;
      }
      aa = (aa + it) % mod;
    }
    if (flag) {
      cout << bb << " " << it << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
