#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, num;
long long fir, d;
bool vis[200020 << 1];
long long cal(long long *a, long long n, long long dx) {
  long long now = 0;
  for (long long i = 1; i <= n; i++) {
    long long x = (a[i] + dx) % m;
    long long l = 1, r = n, ret = 0;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      if (a[mid] == x) {
        ret = mid;
        break;
      } else if (a[mid] < x)
        l = mid + 1;
      else
        r = mid - 1;
    }
    if (ret) now++;
  }
  return now;
}
long long qm(long long a, long long b) {
  long long ret = 1, t = a;
  while (b) {
    if (b & 1) ret = ret * t % m;
    t = t * t % m;
    b >>= 1;
  }
  return ret;
}
map<long long, long long> pos;
void solve(long long *a, long long n) {
  sort(a, a + 1 + n);
  long long dx = (a[2] - a[1] + m) % m;
  long long cnt = cal(a, n, dx);
  long long k = n - cnt, ki = qm(k, m - 2);
  d = (long long)dx * ki % m;
  pos.clear();
  for (long long i = 1; i <= n; i++) pos[a[i]] = i;
  long long x, now, next, num = 0;
  for (x = a[1], now = 1;; x = next) {
    num++;
    next = (x - d + m) % m;
    if (!pos[next]) break;
    now = pos[next];
  }
  fir = a[now];
  for (x = a[1], now = 1;; x = next) {
    num++;
    next = (x + d + m) % m;
    if (!pos[next]) break;
    now = pos[next];
  }
  if (num != n + 1) fir = -1;
}
long long a[200020], b[200020];
int main() {
  m = read(), n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  if (n == 1 || n == m) {
    printf("%lld 1\n", a[1]);
    return 0;
  }
  if (n * 2 <= m)
    solve(a, n);
  else {
    for (long long i = 1; i <= n; i++) vis[a[i]] = 1;
    for (long long i = 0; i < m; i++)
      if (!vis[i]) b[++num] = i;
    solve(b, num);
    if (fir != -1) fir = (fir + num * d) % m;
  }
  if (fir == -1)
    printf("%lld\n", fir);
  else
    printf("%lld %lld\n", fir, d);
}
