#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long m, n, x;
vector<long long> a, c, b;
vector<long long>::iterator it;
long long pow(long long x, long long n, long long m) {
  if (n == 0) return 1 % m;
  if (n & 1) return (x * pow(x, n ^ 1, m)) % m;
  long long t = pow(x, n >> 1, m);
  return (t * t) % m;
}
long long divide(long long a, long long b, long long m) {
  return (a * pow(b, m - 2, m)) % m;
}
bool is_good_difference(long long d, long long& first) {
  long long y = c[0];
  long long cnt = 0;
  it = lower_bound(c.begin(), c.end(), y);
  while (it != c.end() && *it == y) {
    y += d;
    if (y >= m) y -= m;
    cnt++;
    it = lower_bound(c.begin(), c.end(), y);
  }
  y = c[0];
  it = lower_bound(c.begin(), c.end(), y);
  while (it != c.end() && *it == y) {
    first = y;
    y -= d;
    if (y < 0) y += m;
    cnt++;
    it = lower_bound(c.begin(), c.end(), y);
  }
  return (cnt == n + 1);
}
long long count_difference(long long d) {
  long long cnt = 0;
  for (long long i = 0; i <= n - 1; i++) {
    for (long long add = -d; add <= d; add += 2 * d) {
      long long y = c[i] + add;
      if (y >= m) y -= m;
      if (y < 0) y += m;
      if (c[i] > y) continue;
      it = lower_bound(c.begin(), c.end(), y);
      if (it != c.end() && *it == y) cnt++;
    }
  }
  return cnt;
}
pair<long long, long long> solve() {
  if (n == 0) return make_pair(1, 1);
  if (n == 1) return make_pair(c[0], 1);
  sort(c.begin(), c.end());
  long long first;
  long long difference = c[1] - c[0];
  long long k = n - count_difference(difference);
  long long d = divide(difference, k, m);
  if (is_good_difference(d, first)) {
    return make_pair(first, d);
  } else
    return make_pair(-1, -1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> m >> n;
  for (long long i = 1; i <= n; i++) cin >> x, a.push_back(x);
  if (n == 1) {
    cout << a[0] << " " << 1 << endl;
    return 0;
  }
  pair<long long, long long> res = make_pair(-1, -1);
  if (2 * n >= m) {
    sort(a.begin(), a.end());
    b.clear();
    for (long long i = 0; i <= m - 1; i++) {
      it = lower_bound(a.begin(), a.end(), i);
      if (it == a.end() || *it != i) b.push_back(i);
    }
    n = m - n;
    c = b;
    pair<long long, long long> now = solve();
    if (now.first > -1) {
      res.second = now.second;
      res.first = (now.first + n * now.second) % m;
    }
  } else {
    c = a;
    res = solve();
  }
  if (res.first == -1) {
    cout << -1;
    return 0;
  }
  cout << res.first << " " << res.second << endl;
  return 0;
}
