#include <bits/stdc++.h>
using namespace std;
long long num[2][100005], m;
map<long long, int> mp[2];
long long n[2];
long long ans, ansd;
long long pows(long long x, long long k) {
  long long now = 1;
  while (k) {
    if (k % 2) now = (now * x) % m;
    x = (x * x) % m;
    k >>= 1;
  }
  return now;
}
void ok(bool f) {
  long long nowd = abs(num[f][1] - num[f][0]), cnt = 0;
  for (int i = 0; i < n[f]; i++) cnt += mp[f][(num[f][i] + nowd) % m];
  ansd = (pows(n[f] - cnt, m - 2) * nowd) % m;
  cnt = 0;
  for (int i = 0; i < n[f]; i++) {
    if (!mp[f][(num[f][i] + ansd) % m]) {
      cnt++;
      ans = num[f][i];
    }
  }
  if (cnt == 1)
    ansd = m - ansd;
  else
    ans = -1;
}
int main() {
  cin >> m >> n[0];
  for (int i = 0; i < n[0]; i++) {
    scanf("%lld", num[0] + i);
    mp[0][num[0][i]] = 1;
  }
  if (n[0] == 1 || n[0] == m)
    printf("%lld 1\n", num[0][0]);
  else {
    ans = -1;
    if (n[0] * 2 < m)
      ok(0);
    else {
      for (int i = 0; i < m; i++) {
        if (!mp[0][i]) {
          mp[1][i] = 1;
          num[1][n[1]++] = 1LL * i;
        }
      }
      ok(1);
      if (ans != -1) {
        ansd = m - ansd;
        ans = (ans + ansd) % m;
      }
    }
    if (ans != -1)
      printf("%lld %lld\n", ans, ansd);
    else
      printf("-1\n");
  }
  return 0;
}
