#include <bits/stdc++.h>
using namespace std;
inline int power(int a, int b, int mod) {
  int out = 1;
  while (b) {
    if (b & 1) out = 1ll * out * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return out;
}
int ans = -1, ansd = 0;
int m, n, a[200010], b[200010];
inline bool find(int x) { return a[lower_bound(a + 1, a + n + 1, x) - a] == x; }
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  if (n == 1 || n == m) {
    printf("%d 1\n", a[1]);
    return 0;
  }
  bool flag = 0;
  if (2 * n >= m) {
    flag = 1;
    int tmp = 0;
    for (int i = 0; i < m; i++) {
      if (!find(i)) b[++tmp] = i;
    }
    for (int i = 1; i <= tmp; i++) a[i] = b[i];
    n = tmp;
    a[n + 1] = -1;
  }
  if (n == 1) {
    ans = a[1];
    ansd = 1;
  } else {
    int tmp = a[2] - a[1], cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (find((a[i] + tmp) % m)) cnt++;
    }
    ansd = 1ll * tmp * power(n - cnt, m - 2, m) % m;
    int d = (m - ansd) % m;
    for (int i = 1; i <= n; i++) {
      if (!find((a[i] + d) % m)) {
        if (ans == -1)
          ans = a[i];
        else {
          ans = -1;
          break;
        }
      }
    }
  }
  if (flag && ans != -1) ans = (ans + 1ll * ansd * n) % m;
  if (ans == -1)
    puts("-1");
  else
    printf("%d %d\n", ans, ansd);
  return 0;
}
