#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5;
ll a[N];
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d;
  return b == 0 ? (x = 1, y = 0, a)
                : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
}
ll modinv(ll a, ll mod = (ll)1e9 + 7) {
  ll x, y;
  extgcd(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
ll modpow(ll a, ll b, ll mod = (ll)1e9 + 7) {
  ll r = 1;
  a %= mod;
  while (b) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
inline int legendre(ll a, ll p) {
  a %= p;
  if (a < 0) a += p;
  return a == 0 ? 0 : modpow(a, p >> 1, p) == 1 ? 1 : -1;
}
ll modsqrt(ll a, ll p) {
  a = a % p;
  if (a < 0) a += p;
  if (a == 0) return 0;
  if (legendre(a, p) == -1) return -1;
  if (p % 4 == 3) return modpow(a, (p + 1) / 4, p);
  if (p % 8 == 5)
    return modpow(a, (p - 1) / 4, p) == 1
               ? modpow(a, (p + 3) / 8, p)
               : modpow(2, (p - 1) / 4, p) * modpow(a, (p + 3) / 8, p) % p;
  int s = 1;
  ll q = p >> 1;
  while ((q & 1) == 0) q >>= 1, ++s;
  static mt19937 mt;
  ll z;
  do {
    z = 3 + mt() % (p - 3);
  } while (modpow(z, p >> 1, p) == 1);
  int m = s;
  ll c = modpow(z, q, p);
  ll t = modpow(a, q, p);
  ll r = modpow(a, (q + 1) >> 1, p);
  for (; m > 1; --m) {
    ll b = modpow(t, ll(1) << (m - 2), p);
    if (b != 1) r = r * c % p, t = c * c % p * t % p;
    c = c * c % p;
  }
  return r;
}
ll modsqrt(ll a, ll p, ll y) {
  ll x = modsqrt(a, p);
  ll py = 1;
  for (ll i = 0; i < y; i++) py *= p;
  return modpow(x, py / p, py) * modpow(a, (py + 1) / 2 - py / p, py) % py;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll m, n;
  cin >> m >> n;
  ll sum = 0;
  set<ll> st;
  for (int i = 0; i < n; i++) cin >> a[i], sum += a[i], st.emplace(a[i]);
  if (n == 1) {
    cout << a[0] << " " << 0 << endl;
    return 0;
  }
  if (n == m) {
    cout << "1 1" << endl;
    return 0;
  }
  if (n == m - 1) {
    vector<int> e(m);
    for (int i = 0; i < n; i++) e[a[i]] = 1;
    for (int i = 0; i < m; i++)
      if (e[i] == 0) {
        cout << (i + 1) % m << " 1" << endl;
        return 0;
      }
  }
  sum %= m;
  ll mu = sum * modinv(n, m) % m;
  ll sig = 0;
  for (int i = 0; i < n; i++) sig += a[i] * a[i] % m - mu * mu % m;
  sig = sig % m * modinv(n, m) % m;
  sig = (sig % m + m) % m;
  ll dd = 12 * sig % m * modinv(n * n % m - 1, m) % m;
  dd %= m;
  if (legendre(dd, m) == -1) {
    cout << -1 << endl;
    return 0;
  }
  ll d = modsqrt(dd, m);
  ll x = m + mu - (n - 1) * d % m * modinv(2, m) % m;
  x %= m;
  int ok = 1;
  for (int j = 0; j < n; j++) {
    if (!st.count((d * j % m + x) % m)) {
      ok = 0;
      break;
    }
  }
  if (ok) {
    cout << x << " " << d << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}
