#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200010], b[200010];
int gas[200010], cnt;
int ri[200010];
int mod;
bool TNT;
map<int, int> mp;
void pre() {
  ri[1] = 1;
  for (int i = 2; i < 200010; i++) {
    int t = mod / i;
    ri[i] = (1ll * t * (mod - ri[mod % i])) % mod;
  }
}
int main() {
  scanf("%d %d", &m, &n);
  mod = m;
  pre();
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  if (m <= n) {
    for (int i = 0; i < n; i++) {
      gas[a[i]]++;
    }
    int mn = 200010;
    for (int i = 0; i < m; i++) {
      mn = min(mn, gas[i]);
    }
    for (int i = 0; i < m; i++) {
      if (gas[i] > mn + 1) {
        puts("-1");
        return 0;
      }
    }
    if (n % m == 0) {
      printf("0 1\n");
      return 0;
    } else {
      n = n % m;
      cnt = 0;
      for (int i = 0; i < m; i++) {
        if (gas[i] == mn + 1) {
          a[cnt++] = i;
        }
      }
    }
  }
  if (m < 2 * n) {
    memset(gas, 0, sizeof gas);
    for (int i = 0; i < n; i++) {
      gas[a[i]]++;
    }
    cnt = 0;
    for (int i = 0; i < m; i++) {
      if (gas[i] == 0) {
        a[cnt++] = i;
      }
    }
    assert(cnt == m - n);
    n = m - n;
    TNT = true;
  }
  if (n == 1) {
    if (TNT)
      printf("%d %d\n", a[0] + 1, 1);
    else
      printf("%d %d\n", a[0], 1);
    return 0;
  }
  long long tmp = 0;
  for (int i = 0; i < n; i++) {
    tmp = (tmp + a[i]) % mod;
  }
  tmp = (tmp * 2) % mod;
  tmp = (tmp * ri[n]) % mod;
  for (int i = 1; i <= n; i++) {
    b[i] = ((2 * a[i - 1]) % mod + mod - tmp) % mod;
    mp[b[i]] = i;
  }
  if (n & 1) {
    int k = n / 2;
    for (int i = 1; i <= n; i++)
      if (b[i]) {
        bool OK = true;
        for (int j = k; j >= -k; j--) {
          if (mp[(1ll * b[i] * (mod - j)) % mod])
            continue;
          else {
            OK = false;
            break;
          }
        }
        if (OK) {
          int d = (1ll * b[i] * ri[2]) % mod;
          int id = mp[(1ll * b[i] * k) % mod];
          if (TNT)
            printf("%d %d\n", (a[id - 1] + d) % mod, d);
          else
            printf("%d %d\n", a[id - 1], (mod - d) % mod);
          return 0;
        }
      }
    puts("-1");
    return 0;
  } else {
    for (int i = 1; i <= n; i++) {
      if (!b[i]) break;
      bool OK = true;
      for (int j = n - 1; j > -n; j -= 2) {
        if (mp[(1ll * b[i] * (mod - j)) % mod])
          continue;
        else {
          OK = false;
          break;
        }
      }
      if (OK) {
        int d = (mod - b[i]) % mod;
        int id = mp[(1ll * b[i] * (n - 1)) % mod];
        if (TNT)
          printf("%d %d\n", (a[id - 1] + b[i]) % mod, b[i]);
        else
          printf("%d %d\n", a[id - 1], d);
        return 0;
      }
    }
    puts("-1");
    return 0;
  }
}
