#include <bits/stdc++.h>
using namespace std;
using ll = long long;
char buf[16777216];
inline ll Read() {
  static char* c = buf;
  while (*c > '9' || *c < '0') {
    ++c;
  }
  ll ans = *c ^ 48ll;
  while (*(++c) >= '0' && *c <= '9') {
    ans = (ans * 10) + (*c ^ 48ll);
  }
  return ans;
}
ll a[200002], b[200002];
inline bool Find(const ll val) {
  ll l = 1, r = a[0];
  while (l < r) {
    const ll mid = (l + r) >> 1;
    if (a[mid] < val) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  return a[r] == val;
}
int main() {
  fread(buf, 1, 16777216, stdin);
  const ll m = Read(), n = Read();
  for (ll i = 1; i <= n; ++i) {
    a[i] = Read();
  }
  sort(a + 1, a + (n + 1));
  if (n == 1 || n == m) {
    printf("%d 1", static_cast<int>(a[1]));
  } else {
    a[0] = n;
    const bool mode = (n * 2 > m);
    if (mode) {
      for (ll i = 0; i < m; ++i) {
        if (!Find(i)) {
          b[++b[0]] = i;
        }
      }
      for (ll i = 0; i <= b[0]; ++i) {
        a[i] = b[i];
      }
    }
    ll start, d;
    if (a[0] == 1) {
      start = a[1];
      d = 1;
    } else {
      d = a[2] - a[1];
      ll cnt = 0;
      for (ll i = 1; i <= a[0]; ++i) {
        if (Find((a[i] + d) % m)) {
          ++cnt;
        }
      }
      for (ll t1 = (a[0] - cnt) % m, t2 = m - 2; t2 >= 1;
           t1 = t1 * t1 % m, t2 >>= 1) {
        if ((t2 & 1) == 1) {
          d = d * t1 % m;
        }
      }
      start = -1;
      for (ll t = m - d, i = 1; i <= a[0]; ++i) {
        if (!Find((a[i] + t) % m)) {
          if (start != -1) {
            start = -1;
            break;
          }
          start = a[i];
        }
      }
    }
    if (mode && start != -1) {
      start = (start + d * b[0]) % m;
    }
    printf((start == -1 ? "-1" : "%d %d"), static_cast<int>(start),
           static_cast<int>(d));
  }
  return 0;
}
