#include <bits/stdc++.h>
using namespace std;
const int maxn = 200025;
int n, m, i, j, t, k, s, mod, a[maxn], fat[maxn];
bool flg, vis[maxn << 1];
inline int Pow(int x, int y, int mo) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % mo;
    x = 1ll * x * x % mo;
    y >>= 1;
  }
  return ret;
}
int father(int x) { return x == fat[x] ? x : fat[x] = father(fat[x]); }
void solve(int delt) {
  for (i = 1; i <= n; ++i) fat[i] = i;
  for (i = 1; i <= n; ++i) {
    k = (a[i] - delt + mod) % mod;
    t = lower_bound(a + 1, a + n + 1, k) - a;
    if (a[t] == k) fat[father(t)] = father(i);
  }
  t = 0;
  for (i = 1; i <= n; ++i) {
    if (fat[i] == i)
      t++;
    else
      fat[i] = i;
  }
  delt = delt * 1ll * Pow(t, mod - 2, mod) % mod;
  for (i = 1; i <= n; ++i) {
    k = (a[i] - delt + mod) % mod;
    t = lower_bound(a + 1, a + n + 1, k) - a;
    if (a[t] == k) fat[father(t)] = father(i);
  }
  for (i = 2; i <= n; ++i)
    if (father(i) ^ father(1)) break;
  if (i > n) {
    for (i = 1; i <= n; ++i) {
      k = (a[i] - delt + mod) % mod;
      t = lower_bound(a + 1, a + n + 1, k) - a;
      if (a[t] != k) break;
    }
    if (i > n) {
      if (flg)
        printf("%d %d\n", a[1], delt);
      else
        t = (1ll * n * delt + a[1]) % mod, printf("%d %d\n", t, delt);
    } else {
      if (flg)
        printf("%d %d\n", a[i], delt);
      else
        t = (1ll * n * delt + a[i]) % mod, printf("%d %d\n", t, delt);
    }
    exit(0);
  }
}
int main() {
  scanf("%d%d", &mod, &n);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  a[n + 1] = mod + 114514;
  if (n == 1 || n == mod) {
    printf("%d %d\n", a[1], 1);
    return 0;
  }
  if (n == 2) {
    printf("%d %d\n", a[1], (a[2] - a[1] + mod) % mod);
    return 0;
  }
  sort(a + 1, a + n + 1);
  flg = 1;
  if (2 * n > mod) {
    flg = 0;
    for (i = 1; i <= n; ++i) vis[a[i]] = 1;
    n = 0;
    for (i = 0; i < mod; ++i)
      if (!vis[i]) a[++n] = i;
    a[n + 1] = mod + 114514;
    if (n == 1) {
      printf("%d %d\n", (a[1] + 1) % mod, 1);
      return 0;
    }
  }
  solve(a[2] - a[1]);
  solve((a[1] - a[2] + mod) % mod);
  puts("-1");
  return 0;
}
