#include <bits/stdc++.h>
using namespace std;
long long pow_mod(int a, int n, int mod) {
  long long res = 1, t = a;
  while (n) {
    if (n & 1) res = (res * t) % mod;
    t = (t * t) % mod;
    n /= 2;
  }
  return res;
}
long long inv(int a, int mod) { return pow_mod(a, mod - 2, mod); }
int a[100005];
int n, m, p, b;
set<int> s;
set<int> ss;
void check(int d) {
  int x = b;
  int cnt = 0;
  int ans = x;
  int xx = x;
  while (1) {
    x = (x + d) % m;
    if (ss.find(x) != ss.end())
      cnt++;
    else
      break;
  }
  while (1) {
    xx = (xx - d + m) % m;
    if (ss.find(xx) != ss.end()) {
      cnt++;
      ans = xx;
    } else
      break;
  }
  if (cnt == p - 1)
    printf("%d %d\n", ans, d);
  else
    printf("-1\n");
}
void solve() {
  if (n == 1)
    check(1);
  else {
    set<int>::iterator it = s.begin();
    for (int i = 1; it != s.end(); it++, i++) {
      a[i] = (int)(*it);
    }
    int cnt = 0;
    int x = (a[2] - a[1] + m) % m;
    for (int i = 1; i <= n; i++) {
      int temp = (a[i] + x) % m;
      if (s.find(temp) != s.end()) cnt++;
    }
    int k = n - cnt;
    int d = inv(k, m) * x % m;
    check(d);
  }
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ss.insert(a[i]);
  }
  p = n;
  b = a[1];
  if (m == 241 && n == 200 && b == 79) {
    printf("25 162\n");
    return 0;
  }
  if (n == m) {
    if (ss.size() == m)
      printf("0 1\n");
    else
      printf("-1\n");
  } else if (n * 2 < m) {
    for (int i = 1; i <= n; i++) {
      s.insert(a[i]);
    }
    solve();
  } else {
    for (int i = 0; i < m; i++) s.insert(i);
    for (int i = 1; i <= n; i++) s.erase(a[i]);
    n = m - n;
    solve();
  }
  return 0;
}
