#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int res = 0;
  int neg;
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9' || ch == '-') {
      if (ch == '-')
        neg = -1;
      else
        neg = 1, res = ch - '0';
      break;
    }
  }
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9')
      res *= 10, res += ch - '0';
    else
      break;
  }
  return res * neg;
}
const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 1e9 + 7;
int a, b;
int ar[maxn];
int sum;
int mul(int x, int y) { return (long long)x * y % b; }
int add(int x, int y) {
  x += y;
  x %= b;
  if (x < 0) x += b;
  return x;
}
int us(int x, int y) {
  int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
int olda;
int main() {
  scanf("%d %d", &b, &a);
  int h = ((long long)a * (a - 1) / 2) % b;
  int inva = us(a, b - 2);
  int sum = 0;
  for (int i = 1; i <= a; i++) scanf("%d", &ar[i]), sum = add(sum, ar[i]);
  sort(ar + 1, ar + 1 + a);
  if (b == a) {
    printf("0 1\n");
    return 0;
  }
  if (a + a > b) {
    vector<int> v;
    for (int i = 0, j = 1; i < b; i++) {
      while (j <= a && ar[j] < i) j++;
      if (j > a || ar[j] != i) v.push_back(i);
    }
    olda = a;
    a = v.size();
    for (int i = 0; i < v.size(); i++) ar[i + 1] = v[i];
  }
  if (a == 1) {
    if (olda) ar[1] = add(ar[1], 1);
    printf("%d 1\n", ar[1]);
    return 0;
  }
  int d = ar[2] - ar[1];
  int k = a;
  for (int i = 1; i <= a; i++) {
    int t = lower_bound(ar + 1, ar + 1 + a, (ar[i] + d) % b) - ar;
    if ((t <= a && (ar[i] + d) % b == ar[t])) k--;
  }
  d = mul(d, us(k, b - 2));
  int x = ar[1];
  int beg = x;
  int c = 1;
  for (int j = 1; j <= a; j++) {
    x = add(x, d);
    int t = lower_bound(ar + 1, ar + 1 + a, x) - ar;
    if ((t <= a && ar[t] == x))
      c++;
    else
      break;
  }
  int last = x;
  x = beg;
  for (int j = 1; j <= a; j++) {
    x = add(x, -d);
    int t = lower_bound(ar + 1, ar + 1 + a, x) - ar;
    if ((t <= a && ar[t] == x))
      c++;
    else
      break;
  }
  x = add(x, d);
  if (olda > 0) {
    if (c == a) {
      printf("%d %d\n", last, d);
      return 0;
    }
    printf("-1\n");
    return 0;
  }
  if (c == a) {
    printf("%d %d\n", x, d);
    return 0;
  }
  printf("-1\n");
  return 0;
}
