#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long Inf = 1e10;
const int N = 100005;
inline long long IN() {
  long long x = 0;
  int ch = 0, f = 0;
  for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar())
    f = (ch == '-');
  for (; ch >= 48 && ch <= 57; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return f ? (-x) : x;
}
template <typename T>
inline int chkmin(T &a, const T &b) {
  if (b < a) return a = b, 1;
  return 0;
}
template <typename T>
inline int chkmax(T &a, const T &b) {
  if (b > a) return a = b, 1;
  return 0;
}
int P;
void renew(int &x, const int &y) {
  x += y;
  if (x >= P) x -= P;
  if (x < 0) x += P;
}
int Pow(int x, int y, int p) {
  int a = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) a = (long long)a * x % p;
  return a;
}
int a[N], aa[N], n, an, b[N], m;
map<int, int> s;
int main() {
  scanf("%d%d", &P, &n);
  an = n;
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", a + i);
  memcpy(aa, a, sizeof a);
  int tim = 1;
  while (n > 400 && tim <= 60) {
    if (clock() > 1500) {
      puts("-1");
      return 0;
    }
    s.clear();
    for (int i = (int)(1); i <= (int)(n); i++) s[a[i]] = 1;
    int x = (rand() << 15) | rand();
    x = x % n + 1;
    int w = (a[x] << 1) % P;
    m = 0;
    for (int i = (int)(1); i <= (int)(n); i++) {
      if (s.find((w + P - a[i]) % P) == s.end()) {
        b[++m] = a[i];
      }
    }
    n = m;
    for (int i = (int)(1); i <= (int)(n); i++) a[i] = b[i];
  }
  if (tim > 60) {
    puts("-1");
    return 0;
  }
  int res = -1;
  if (n == 1) {
    res = 0;
  } else {
    s.clear();
    for (int i = (int)(1); i <= (int)(n); i++) s[a[i]] = 1;
    for (int i = (int)(2); i <= (int)(n); i++) {
      int diff = (a[i] - a[1] + P) % P, ok = 0;
      for (int i = (int)(1); i <= (int)(n); i++)
        if (s.find((a[i] + diff) % P) == s.end()) {
          ok++;
          if (ok >= 2) break;
        }
      if (ok < 2) {
        res = diff;
        break;
      }
    }
  }
  if (res < 0) {
    puts("-1");
    return 0;
  }
  s.clear();
  for (int i = (int)(1); i <= (int)(an); i++) s[aa[i]] = 1;
  int fir = aa[1];
  for (int i = (int)(2); i <= (int)(an); i++) {
    if (s.find((aa[i] + P - res) % P) == s.end()) {
      fir = aa[i];
      break;
    }
  }
  printf("%d %d\n", fir, res);
  return 0;
}
