#include <bits/stdc++.h>
struct S {
  int i, p, q;
} ss[100000 + 100000];
int pp[20 + 1][100000 + 100000];
int compare_(const void *a, const void *b) {
  struct S *s = (struct S *)a;
  struct S *t = (struct S *)b;
  return s->p != t->p ? s->p - t->p : s->q - t->q;
}
int compare(const void *a, const void *b) {
  int ia = *(int *)a;
  int ib = *(int *)b;
  return ia - ib;
}
int dd[100000 + 100000];
int n_, b;
void init() {
  int a, u, i, i_, p;
  for (i = 0; i < n_; i++) ss[i].i = i;
  while (1 << b < n_) b++;
  for (i = 0; i < n_; i++) pp[0][i] = dd[i];
  for (a = 0; a < b; a++) {
    u = 1 << a;
    for (i = 0; i < n_; i++) {
      int i_ = ss[i].i;
      ss[i].p = pp[a][i_];
      ss[i].q = i_ + u >= n_ ? -1 : pp[a][i_ + u];
    }
    qsort(ss, n_, sizeof *ss, compare_);
    for (i = 0, p = 0; i < n_; i++) {
      i_ = ss[i].i;
      pp[a + 1][i_] =
          i == 0 || (ss[i - 1].p == ss[i].p && ss[i - 1].q == ss[i].q) ? p
                                                                       : ++p;
    }
  }
}
int lcp(int i, int j) {
  int a, l;
  if (i > j) return lcp(j, i);
  l = 0;
  for (a = b - 1; a >= 0 && j < n_; a--)
    if (pp[a][i] == pp[a][j]) {
      int u = 1 << a;
      i += u;
      j += u;
      l += u;
    }
  return l;
}
int good(int *aa, int n, int x) {
  int lower = -1, upper = n;
  while (upper - lower > 1) {
    int i = (lower + upper) / 2;
    if (aa[i] <= x)
      lower = i;
    else
      upper = i;
  }
  return lower >= 0 && aa[lower] == x;
}
int main() {
  static int aa[100000];
  int m, n, h, i, j;
  scanf("%d%d", &m, &n);
  if (n == m) {
    printf("0 1\n");
    return 0;
  }
  for (i = 0; i < n; i++) scanf("%d", &aa[i]);
  if (n == 1) {
    printf("%d 0", aa[0]);
    return 0;
  }
  qsort(aa, n, sizeof *aa, compare);
  n_ = n + n - 1;
  for (i = 0; i < n_; i++) {
    dd[i] = aa[(i + 1) % n] - aa[i % n];
    if (dd[i] < 0) dd[i] += m;
  }
  init();
  for (h = 1; h < n; h++) {
    int first, last;
    int x = aa[h] - aa[0];
    i = 0;
    j = h;
    first = last = -1;
    while (1) {
      int l = lcp(i, j);
      i += l + 1;
      j += l + 1;
      if (j >= h + n) {
        printf("%d %d\n", first, x);
        return 0;
      }
      while (!good(aa, n, (aa[i % n] + x) % m)) {
        if (last != -1) goto end;
        last = aa[i % n];
        i++;
      }
      while (!good(aa, n, (aa[j % n] - x + m) % m)) {
        if (first != -1) goto end;
        first = aa[j % n];
        j++;
      }
    }
  end:;
  }
  printf("-1\n");
  return 0;
}
