#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int INF = 0x3f3f3f3f;
int mod;
void MOD(long long &a) {
  if (a >= mod) a -= mod;
}
void MOD(long long &a, long long c) {
  if (a >= c) a -= c;
}
void ADD(long long &a, long long b) {
  a += b;
  MOD(a);
}
void ADD(long long &a, long long b, long long c) {
  a += b;
  MOD(a, c);
}
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ans;
}
long long qpow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b /= 2;
  }
  return ans;
}
int n, a[N], b[N];
map<int, int> mp;
int ans, d, times;
void solve(int *a, int n) {
  if (n == 1) {
    ans = a[1];
    d = 1;
    times = 1;
    return;
  }
  int kd = a[2] - a[1];
  for (int i = 1; i <= n; i++) mp[a[i]]++;
  int num = 0;
  for (int i = 1; i <= n; i++) {
    if (mp.find((a[i] + kd) % mod) != mp.end()) num += mp[(a[i] + kd) % mod];
  }
  d = (1ll * kd * qpow(n - num, mod - 2)) % mod;
  int now = a[1];
  ans = a[1];
  times = 0;
  while (mp[now]) {
    ans = now;
    mp[now]--;
    now = ((now - d) % mod + mod) % mod;
    times++;
  }
  now = (a[1] + d) % mod;
  while (mp[now]) {
    mp[now]--;
    now = (now + d) % mod;
    times++;
  }
}
int main() {
  scanf("%lld%d", &mod, &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  if (n == 1 || n == mod)
    printf("%d %d\n", a[1], 1);
  else if (2 * n < mod + 2) {
    solve(a, n);
    if (times == n)
      printf("%d %d\n", ans, d);
    else
      printf("-1\n");
  } else {
    int now = 1, st = 1;
    for (int i = 0; i < mod; i++)
      if (a[st] == i)
        st++;
      else
        b[now++] = i;
    solve(b, mod - n);
    ans = (1ll * ans + 1ll * (mod - n) * d % mod) % mod;
    if (times == mod - n)
      printf("%d %d\n", ans, d);
    else
      printf("-1\n");
  }
}
