#include <bits/stdc++.h>
using namespace std;
set<long long> s;
long long l, d;
long long power(long long a, long long n, long long m) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return ans;
}
long long mi(long long b, long long m) { return power(b, m - 2, m); }
bool solve(long long m, long long n) {
  set<long long>::iterator it = s.begin();
  long long k = n, x = (long long)abs(*(it) - *(++it));
  for (it = s.begin(); it != s.end(); it++) {
    if (s.find(*it + x) != s.end()) k--;
    if (s.find(*it + m - x) != s.end()) k--;
  }
  d = x * mi(k, m) % m;
  long long r, cnt = 1;
  l = r = *s.begin();
  while (s.find((l + m - d) % m) != s.end()) {
    cnt++;
    l = (l + m - d) % m;
  }
  while (s.find((r + d) % m) != s.end()) {
    cnt++;
    r = (r + d) % m;
  }
  if (cnt == n)
    return true;
  else
    return false;
}
int main() {
  long long m, n, a;
  s.clear();
  scanf("%I64d%I64d", &m, &n);
  if (n == 1) {
    scanf("%I64d", &a);
    printf("%I64d 0", a);
    return 0;
  }
  if (2 * n < m + 3) {
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &a);
      s.insert(a);
    }
    if (solve(m, n)) {
      printf("%I64d %I64d", l, d);
    } else {
      printf("-1");
    }
  } else {
    set<int> tmp;
    tmp.clear();
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &a);
      tmp.insert(a);
    }
    for (long long i = 0; i < m; i++)
      if (tmp.find(i) == tmp.end()) s.insert(i);
    if (m - n == 1) {
      printf("%I64d 1", *s.begin() + 1);
      return 0;
    }
    if (m - n == 0) {
      printf("%I64d 1", a);
      return 0;
    }
    if (solve(m, m - n)) {
      printf("%I64d %I64d", (l + (m - n) * d) % m, d);
    } else {
      printf("-1");
    }
  }
}
