#include <bits/stdc++.h>
int F(const void* x, const void* y) { return *(unsigned*)x - *(unsigned*)y; }
unsigned A[111111], D[111111], A_R[111111], I[222222], Di, n, m;
unsigned chk(unsigned x, unsigned* P) {
  unsigned lo = 0, hi = n, mi;
  while ((mi = (lo + hi) >> 1) > lo) {
    if (P[mi] > x)
      hi = mi;
    else
      lo = mi;
  }
  return P[lo] == x;
}
unsigned sol(unsigned x, unsigned d, unsigned* P) {
  unsigned l = 1, a, b;
  if ((a = x + m - d) >= m) a -= m;
  if ((b = x + d) >= m) b -= m;
  while (l < n) {
    if (chk(a, P)) {
      if ((a += m - d) >= m) a -= m;
      ++l;
    } else if (chk(b, P)) {
      if ((b += d) >= m) b -= m;
      ++l;
    } else
      return -1;
  }
  if ((a += d) >= m) a -= m;
  return a;
}
unsigned tle_rescue() {
  unsigned i, j = 0, k, x = n;
  n = 0;
  for (i = -1; ++i < x;) I[A[i]] = 1;
  for (i = -1; ++i < m;)
    if (!I[i]) A_R[n++] = i;
  for (i = 0; ++i < n; D[j++] = k) {
    if ((k = A_R[i] + m - *A_R) >= m) k -= m;
    if (k > m - k) k = m - k;
  }
  qsort(D, j, sizeof(unsigned), F);
  if (!j) D[j++] = 1;
  for (Di = i = 0; ++i < j;)
    if (D[i] != D[Di]) D[++Di] = D[i];
  for (++Di; Di--;)
    if ((i = sol(*A_R, D[Di], A_R)) != -1u) {
      n = x;
      i = sol(*A, D[Di], A);
      if (i == -1u) {
        printf("My theorem is broken :( I'm stupid at math!\n");
      } else
        printf("%u %u\n", i, D[Di]);
      return 0;
    }
  printf("-1\n");
  return 0;
}
int main() {
  unsigned i = -1, j = 0, k;
  for (scanf("%u%u", &m, &n); ++i < n;) scanf("%u", A + i);
  qsort(A, n, sizeof(unsigned), F);
  if (m < n + n) {
    tle_rescue();
    return 0;
  }
  for (i = 0; ++i < n; D[j++] = k) {
    if ((k = A[i] + m - *A) >= m) k -= m;
    if (k > m - k) k = m - k;
  }
  if (!j) D[j++] = 1;
  qsort(D, j, sizeof(unsigned), F);
  for (Di = i = 0; ++i < j;)
    if (D[i] != D[Di]) D[++Di] = D[i];
  for (++Di; Di--;)
    if ((i = sol(*A, D[Di], A)) != -1u) {
      printf("%u %u\n", i, D[Di]);
      return 0;
    }
  printf("-1\n");
  return 0;
}
