#include <bits/stdc++.h>
using namespace std;
const int inf = 987654321;
const long long int INF = 123456789987654321;
FILE *fin, *fout;
int M, N;
int pw(int x, int n) {
  long long int ret = 1, a = x;
  while (n) {
    if (n & 1) ret = ret * a % M;
    a = a * a % M;
    n /= 2;
  }
  return (int)ret;
}
int modInv(int x) { return pw(x, M - 2); }
vector<int> arr, chk;
bool f(int x) {
  int s = 0, e = arr.size() - 1;
  while (s <= e) {
    int m = (s + e) >> 1;
    if (arr[m] == x)
      return true;
    else if (arr[m] < x)
      s = m + 1;
    else
      e = m - 1;
  }
  return false;
}
int main() {
  scanf("%d %d", &M, &N);
  arr.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
  }
  if (N > M) {
    printf("-1");
    return 0;
  }
  if (2 * N > M) {
    chk = vector<int>(M, 0);
    for (int i = 0; i < N; i++) {
      chk[arr[i]] = 1;
    }
    arr.clear();
    for (int i = 0; i < M; i++) {
      if (!chk[i]) arr.push_back(i);
    }
  }
  if (arr.size() == 0) {
    printf("%d %d", arr[0], 1);
    return 0;
  }
  if (arr.size() == 1) {
    if (2 * N <= M)
      printf("%d %d", arr[0], 1);
    else
      printf("%d %d", (arr[0] + 1) % M, 1);
    return 0;
  }
  sort((arr).begin(), (arr).end());
  int x = arr[1] - arr[0];
  int cnt = 0;
  for (int i = 0; i < arr.size(); i++) {
    if (f((arr[i] - x + M) % M)) cnt++;
    if (f((arr[i] + x) % M)) cnt++;
  }
  int k = arr.size() - cnt / 2;
  int d = (int)((long long int)x * modInv(k) % M);
  int cur, s = 0, e = 0;
  cnt = 0;
  cur = arr[0];
  while (f(cur)) {
    cnt++;
    s = cur;
    cur = (cur - d + M) % M;
  }
  cur = (arr[0] + d) % M;
  while (f(cur)) {
    cnt++;
    e = cur;
    cur = (cur + d) % M;
  }
  if (cnt != arr.size())
    printf("-1");
  else if (2 * N < M)
    printf("%d %d", s, d);
  else
    printf("%d %d", (e + d) % M, d);
}
