#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void amax(X& x, const Y& y) {
  if (x < y) x = y;
}
template <class X, class Y>
void amin(X& x, const Y& y) {
  if (x > y) x = y;
}
const int INF = 1e9 + 10;
const long long INFL = 1e18 + 10;
const int MAX = 2e5 + 10;
int m, n, nb;
int a[MAX], b[MAX];
set<int> exist, existb;
long long mul(long long a, long long b) { return (a * b) % m; }
long long power(long long x, long long n) {
  if (n == 0) return 1;
  long long tmp = power(x, n / 2);
  tmp = mul(tmp, tmp);
  if (n & 1) tmp = mul(tmp, x);
  return tmp;
}
void check(int x, int d) {
  for (int i = 0; i < n; i++)
    if (exist.find((x + mul(d, i)) % m) == exist.end()) return;
  cout << x << " " << d;
  exit(0);
}
void process() {
  cin >> m >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    exist.insert(a[i]);
  }
  if (n == 1) {
    cout << a[1] << " " << 0;
    return;
  }
  if (n == m) {
    cout << 0 << " " << 1;
    return;
  }
  if (n == m - 1) {
    if (exist.find(0) == exist.end()) {
      cout << 1 << " " << 1;
      return;
    }
    int t = 0;
    for (int i = 0; i < m; i++)
      if (exist.find(i) == exist.end()) {
        t = i;
        break;
      }
    cout << 0 << " " << mul(t, power(n, m - 2));
    return;
  }
  if (n * 2 < m) {
    nb = n;
    for (int i = 1; i <= n; i++) b[i] = a[i];
    existb = exist;
  } else {
    for (int i = 0; i < m; i++)
      if (exist.find(i) == exist.end()) {
        b[++nb] = i;
        existb.insert(i);
      }
  }
  int t = (b[2] - b[1] + m) % m;
  int cnt = 0;
  for (int i = 1; i <= nb; i++)
    if (existb.find((b[i] + t) % m) != existb.end()) cnt++;
  int d = mul(t, power(nb - cnt, m - 2));
  int sum = 0;
  for (int i = 1; i <= nb; i++) sum = (sum + b[i]) % m;
  sum = (sum + sum) % m;
  sum = mul(sum, power(nb, m - 2));
  if (nb == n) {
    int x = mul(power(2, m - 2), (sum - mul(d, nb - 1) + m) % m);
    check(x, d);
    x = mul(power(2, m - 2), (sum - mul(m - d, nb - 1) + m) % m);
    check(x, m - d);
  } else {
    int x = mul(power(2, m - 2), (sum - mul(d, nb - 1) + m) % m);
    check((x - mul(n, d) + m) % m, d);
    x = mul(power(2, m - 2), (sum - mul(m - d, nb - 1) + m) % m);
    check((x - mul(n, m - d) + m) % m, m - d);
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  process();
}
