#include <bits/stdc++.h>
using namespace std;
int IN() {
  int c, f, x;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0');
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0';
  return !f ? x : -x;
}
const int N = 100000 + 19;
int Pow(int a, int b, int p) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % p)
    if (b & 1) res = 1ll * res * a % p;
  return res;
}
map<int, int> M;
int m, n, flg, x, d, tmp, cnt, num, now;
int A[N], vis[2 * N];
void Work() {
  if (n == 1) {
    x = A[1];
    d = 1;
    return;
  }
  tmp = (A[2] - A[1] + m) % m;
  for (int i = 1; i < n + 1; i++) M[A[i]] = 1;
  for (int i = 1; i < n + 1; i++) {
    if (M.count((A[i] + tmp) % m)) cnt++;
  }
  cnt = n - cnt;
  d = 1ll * tmp * Pow(cnt, m - 2, m) % m;
  num = 1;
  x = A[1];
  for (now = (A[1] - d + m) % m;; now = (now - d + m) % m) {
    if (!M.count(now)) break;
    num++, x = now;
  }
  for (now = (A[1] + d) % m;; now = (now + d) % m) {
    if (!M.count(now)) break;
    num++;
  }
  if (num != n) {
    puts("-1");
    exit(0);
  }
}
int main() {
  m = IN(), n = IN();
  for (int i = 1; i < n + 1; i++) A[i] = IN();
  if (n == m) {
    printf("%d %d\n", 0, 1);
    return 0;
  }
  if (n > m - n) {
    for (int i = 1; i < n + 1; i++) vis[A[i]] = 1;
    n = 0;
    for (int i = 0; i < m; i++)
      if (!vis[i]) A[++n] = i;
    flg = 1;
  }
  Work();
  if (flg) {
    printf("%d %d\n", (x - d + m) % m, m - d);
  } else {
    printf("%d %d\n", x, d);
  }
}
