#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int A[maxn], B[maxn], N, MOD, fir, d, len;
int ksm(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = (long long)x * x % MOD)
    if (y & 1) res = (long long)res * x % MOD;
  return res;
}
void Solve(int *P, int Len) {
  int kd = P[1] - P[0], cnt = 0;
  map<int, bool> vis;
  for (int i = 0; i < N; ++i) vis[P[i]] = true;
  for (int i = 0; i < N; ++i)
    if (!vis.count((P[i] + kd) % MOD)) ++cnt;
  d = (long long)kd * ksm(cnt, MOD - 2) % MOD;
  fir = -1;
  len = (MOD - d) % MOD;
  for (int i = 0; i < N; ++i)
    if (!vis.count((P[i] + d) % MOD))
      if (~fir) {
        fir = -1;
        break;
      } else
        fir = P[i];
}
int main() {
  MOD = read();
  N = read();
  for (int i = 0; i < N; ++i) A[i] = read();
  if (N == 1 || N == MOD)
    printf("%d 1\n", A[0]);
  else {
    sort(A, A + N);
    if (2 * N < MOD)
      Solve(A, N);
    else {
      map<int, bool> vis;
      for (int i = 0; i < N; ++i) vis[A[i]] = true;
      N = 0;
      for (int i = 0; i < MOD; ++i)
        if (!vis.count(i)) B[N++] = i;
      Solve(B, N);
      if (~fir) (fir += (long long)len * N % MOD) %= MOD;
    }
    if (~fir)
      printf("%d %d\n", fir, len);
    else
      puts("-1");
  }
}
