#include <bits/stdc++.h>
using namespace std;
long long m, n;
set<long long> a;
set<long long> b;
set<long long>::iterator it;
vector<long long> order;
long long binPow(long long a, long long q) {
  long long ret = 1;
  for (long long i = 0; (1LL << i) <= q; i++) {
    if (q & (1LL << i)) ret = (ret * a) % m;
    a = (a * a) % m;
  }
  return ret;
}
long long diff;
void presolve() {
  bool sw = false;
  if (n * 2 > m) {
    for (long long i = 0; i < m; i++)
      if (a.find(i) == a.end()) b.insert(i);
    a.swap(b);
    sw = true;
    n = a.size();
  }
  diff = *a.rbegin() - *a.begin();
  long long cnt = 0;
  for (it = a.begin(); it != a.end(); it++) {
    long long t = (*it + diff) % m;
    if (a.find(t) != a.end()) cnt++;
  }
  cnt = n - cnt;
  diff = (diff * binPow(cnt, m - 2)) % m;
  if (sw) a.swap(b);
  b = a;
}
void solve() {
  long long sta = *a.begin();
  a.erase(a.begin());
  while (1) {
    long long nxt = ((sta - diff) % m + m) % m;
    if (a.find(nxt) == a.end()) break;
    sta = nxt;
    a.erase(a.find(sta));
  }
  long long cur = sta;
  while (1) {
    if (b.find(cur) == b.end()) {
      cout << -1 << '\n';
      exit(0);
    }
    b.erase(b.find(cur));
    if (b.size() == 0) break;
    cur = (cur + diff) % m;
  }
  cout << sta << ' ' << diff << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> m >> n;
  for (long long i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    a.insert(t);
  }
  if (n == 1) {
    cout << *a.begin() << ' ' << 0 << '\n';
    return 0;
  }
  if (n == m - 1) {
    long long nf = -1;
    for (long long i = 0; i < m; i++)
      if (a.find(i) == a.end()) {
        nf = i;
        break;
      }
    if (nf == m - 1)
      cout << 0 << ' ' << 1 << '\n';
    else
      cout << nf + 1 << ' ' << 1 << '\n';
    return 0;
  }
  if (n == m) {
    cout << 0 << ' ' << 1 << '\n';
    return 0;
  }
  presolve();
  solve();
}
