#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int mod;
int a[maxn];
void ExEuclid(long long a, long long b, long long &x, long long &y,
              long long &q) {
  if (b == 0) {
    x = 1;
    y = 0;
    q = a;
    return;
  }
  ExEuclid(b, a % b, y, x, q);
  y -= x * (a / b);
}
long long inv(long long num) {
  long long x, y, q;
  ExEuclid(num, mod, x, y, q);
  if (q == 1) return (x + mod) % mod;
}
int main() {
  int m, n;
  cin >> m >> n;
  mod = m;
  int sum = 0;
  unordered_set<int> Set;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
    sum %= mod;
    Set.insert(a[i]);
  }
  for (int i = 0; i < n; i++) {
    long long tmp = (long long)a[i] * n;
    tmp %= m;
    tmp = sum - tmp + m;
    tmp %= m;
    long long d = tmp * inv(((long long)n * (n - 1) / 2) % m);
    d %= m;
    if (d == 0) {
      d = 1;
    }
    if (d == 0 && n != 1) {
      continue;
    }
    bool ok = 1;
    int cur = a[i];
    if (n + n < m) {
      for (int j = 1; j < n; j++) {
        cur += d;
        if (cur >= m) {
          cur -= m;
        }
        if (Set.count(cur) == 0) {
          ok = 0;
          break;
        }
      }
    } else {
      for (int j = 1; j + n <= m; j++) {
        cur -= d;
        if (cur < 0) {
          cur += m;
        }
        if (Set.count(cur) == 1) {
          ok = 0;
          break;
        }
      }
    }
    if (ok) {
      cout << a[i] << " " << d << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
