#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int M, a[MAXN];
set<int> S1, S2;
long long Pow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % M;
    x = (x * x) % M;
    y >>= 1;
  }
  return ans;
}
pair<int, int> solve(const set<int> &S) {
  int N = S.size();
  if (N == 0) return make_pair(0, 1);
  set<int>::iterator iter = S.begin();
  int cnt = 1, a0 = *iter;
  if (N == 1) return make_pair(a0, 1);
  int dif = (*(++iter) - a0 + M) % M;
  for (; iter != S.end(); ++iter) cnt += (S.find((*iter + dif) % M) != S.end());
  int d = (dif * Pow(N - cnt, M - 2)) % M;
  cnt = 1;
  int x = a0, y = a0;
  while (S.find((x - d + M) % M) != S.end()) ++cnt, x = (x - d + M) % M;
  while (S.find((y + d) % M) != S.end()) ++cnt, y = (y + d) % M;
  return cnt == N ? make_pair(x, d) : make_pair(-1, -1);
}
int main() {
  int N;
  scanf("%d%d", &M, &N);
  for (int i = 0; i < N; ++i) scanf("%d", a + i), S1.insert(a[i]);
  if (M > 2 * N - 2) {
    pair<int, int> ans = solve(S1);
    if (ans.first >= 0)
      printf("%d %d\n", ans.first, ans.second);
    else
      printf("-1\n");
  } else {
    for (int i = 0; i < M; ++i)
      if (S1.find(i) == S1.end()) S2.insert(i);
    pair<int, int> ans = solve(S2);
    if (ans.first >= 0)
      printf("%d %d\n", (ans.first - ans.second + M) % M, M - ans.second);
    else
      printf("-1\n");
  }
  return 0;
}
