#include <bits/stdc++.h>
using namespace std;
int mod, n;
long long gm(long long x) { return (x % mod + mod) % mod; }
long long fp(long long x, long long k) {
  if (k == 0) return 1;
  long long hf = fp(x, k / 2);
  return k % 2 ? hf * hf % mod * x % mod : hf * hf % mod;
}
long long inv(long long x) { return fp(x, mod - 2); }
int count(long long d, vector<long long> &a) {
  map<long long, int> mp;
  int res = 0;
  for (int i = 0; i < a.size(); i++) {
    res += mp[gm(a[i] - d)] + mp[gm(a[i] + d)];
    mp[a[i]]++;
  }
  return res;
}
pair<long long, long long> solve(vector<long long> num) {
  int n = num.size();
  if (n == 0) return {0, 1};
  if (n == 1) return {num[0], 1};
  long long dif = gm(num[1] - num[0]);
  int cnt = count(dif, num);
  long long ans_d = gm(dif * inv(n - cnt));
  map<long long, int> mp;
  for (int i = 0; i < n; i++) mp[num[i]]++;
  long long cur = num[0];
  while (true) {
    long long nxt = gm(cur - ans_d);
    if (!mp.count(nxt)) break;
    cur = nxt;
  }
  for (int i = 0; i < n; i++) {
    if (!mp.count(gm(cur + ans_d * i))) return {-1, -1};
  }
  return {cur, ans_d};
}
vector<long long> a;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> mod >> n;
  a.resize(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (2 * n < mod + 1) {
    pair<long long, long long> p = solve(a);
    if (p.first == -1)
      cout << "-1" << endl;
    else
      cout << p.first << " " << p.second << endl;
  } else {
    map<long long, int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;
    vector<long long> b;
    for (int i = 0; i < mod; i++)
      if (!mp.count(i)) b.push_back(i);
    pair<long long, long long> p = solve(b);
    if (p.first == -1)
      cout << "-1" << endl;
    else
      cout << gm(p.first + (mod - n) * p.second) << " " << p.second << endl;
  }
}
