#include <bits/stdc++.h>
using namespace std;
int n, m, num;
vector<int> a, gi;
vector<pair<int, int> > d;
int bpow(long long x, long long p, long long mod) {
  long long res = 1;
  while (p) {
    if (p % 2) {
      res = (res * x) % mod;
      --p;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res;
}
bool ok(long long d, long long x) {
  if (num > 5e8) return false;
  for (int i = 0; i < n; ++i) {
    int j = lower_bound(a.begin(), a.end(), x) - a.begin();
    if (j == n || a[j] != x) return false;
    x += d;
    if (x >= m) x -= m;
    ++num;
  }
  return true;
}
bool okk(long long d, long long x) {
  if (num > 5e8) return false;
  for (int i = 0; i < n; ++i) {
    if (gi[x] == 0) return false;
    x += d;
    if (x >= m) x -= m;
    ++num;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> m >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  bool fl = true;
  for (int i = 1; i < n; ++i) {
    if (a[i] != a[i - 1]) fl = false;
  }
  if (fl) {
    cout << a[0] << " " << 0 << endl;
    return 0;
  }
  if (n % m == 0) {
    int k = n / m;
    gi.assign(m, 0);
    for (int i = 0; i < n; ++i) ++gi[a[i]];
    for (int i = 0; i < m; ++i) {
      if (gi[i] != k) {
        cout << -1 << endl;
        return 0;
      }
    }
    cout << 0 << " " << 1 << endl;
    return 0;
  }
  if (n > m) {
    int k = n / m;
    vector<int> gi(m, 0);
    for (int i = 0; i < n; ++i) ++gi[a[i]];
    for (int i = 0; i < m; ++i) {
      if (gi[i] == k || gi[i] == k + 1)
        gi[i] -= k;
      else {
        cout << -1 << endl;
        return 0;
      }
    }
    a.resize(0);
    for (int i = 0; i < m; ++i) {
      if (gi[i] > 0) a.push_back(i);
    }
    n = a.size();
  }
  sort(a.begin(), a.end());
  d.resize(n + n - 2);
  for (int i = 1; i < n; ++i) {
    int dd = (m + a[i] - a[0]) % m;
    d[i + i - 2].first = dd;
    d[i + i - 1].first = (m - dd) % m;
  }
  long long sum = (accumulate(a.begin(), a.end(), 0ll)) % m;
  long long mul = ((n * 1ll * (n - 1ll)) / 2ll) % m;
  long long po = bpow(n, m - 2, m);
  for (int i = 0; i < d.size(); ++i) {
    long long xx = (sum + m - (mul * d[i].first) % m) % m;
    d[i].second = (xx * po) % m;
  }
  num = 0;
  sort(d.begin(), d.end());
  d.resize(unique(d.begin(), d.end()) - d.begin());
  if (m > 1e7) {
    for (int i = 0; i < d.size(); ++i) {
      if (ok(d[i].first, d[i].second)) {
        cout << d[i].second << " " << d[i].first << endl;
        return 0;
      }
    }
  } else {
    gi.assign(m, 0);
    for (int i = 0; i < n; ++i) ++gi[a[i]];
    for (int i = 0; i < d.size(); ++i) {
      if (okk(d[i].first, d[i].second)) {
        cout << d[i].second << " " << d[i].first << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
