#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
bool chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
T read() {
  T x = 0, f = 1;
  char c = getchar();
  while ((c < '0') || (c > '9')) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ((c >= '0') && (c <= '9'))
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
template <typename T>
void write(T x, char c) {
  static char t[25];
  static int tlen;
  t[tlen = 1] = c;
  if (x < 0) putchar('-'), x = -x;
  do t[++tlen] = (x % 10) ^ 48;
  while (x /= 10);
  while (tlen) putchar(t[tlen--]);
}
const int maxn = 100005;
int n, mod, a[maxn];
map<int, bool> vis;
int ksm(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod, y >>= 1;
  }
  return res;
}
int main() {
  mod = read<int>(), n = read<int>();
  int sum = 0;
  for (int i = 1, iend = n; i <= iend; ++i)
    a[i] = read<int>(), sum = (sum + a[i]) % mod, vis[a[i]] = 1;
  if ((n == mod) || (n == 1)) {
    printf("%d %d\n", a[1], 1);
    return 0;
  } else if (n == mod - 1) {
    sort(a + 1, a + 1 + n);
    for (int i = 2, iend = n; i <= iend; ++i)
      if (a[i] != a[i - 1] + 1) {
        printf("%d %d\n", a[i], 1);
        break;
      }
    return 0;
  }
  int x = 0, y = 0;
  bool mark = 0;
  if (n >= mod / 2) {
    int t = 0;
    mark = 1, n = mod - n;
    for (int i = 0, iend = mod - 1; i <= iend; ++i) {
      if (!vis[i])
        a[++t] = i;
      else
        vis[i] = 0;
    }
    sum = 0;
    for (int i = 1, iend = n; i <= iend; ++i)
      sum = (sum + a[i]) % mod, vis[a[i]] = 1;
  }
  for (int i = 1, iend = n; i <= iend; ++i) {
    bool flag = 1;
    int d = (sum % mod - 1ll * a[i] * n % mod) *
            ksm(1ll * n * (n - 1) / 2 % mod, mod - 2) % mod;
    if (d < 0) d += mod;
    if ((d == 0) || (d > mod / 2)) continue;
    for (int j = 1, jend = n - 1; j <= jend; ++j)
      if (!vis[(a[i] + 1ll * j * d % mod) % mod]) {
        flag = 0;
        break;
      }
    if (flag) {
      x = a[i], y = d;
      break;
    }
  }
  if (!y) {
    puts("-1");
    return 0;
  }
  if (mark) x = ((x - 1ll * (mod - n) * y) % mod + mod) % mod;
  write(x, ' '), write(y, '\n');
  return 0;
}
