#include <bits/stdc++.h>
using namespace std;
static int n = 0;
static long long m = 0;
static vector<int> a;
long long pow(long long x, int n, long long m) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (x * pow(x, n ^ 1, m)) % m;
  } else {
    long long t = pow(x, n >> 1, m);
    return (t * t) % m;
  }
}
long long divide(long long a, long long b, long long m) {
  return (a * pow(b, m - 2, m)) % m;
}
int count_differences(int d) {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int add = -d; add <= d; add += 2 * d) {
      int y = a[i] + add;
      if (y >= m) {
        y -= m;
      }
      if (y < 0) {
        y += m;
      }
      if (a[i] > y) {
        continue;
      }
      auto it = lower_bound(a.begin(), a.end(), y);
      if (it != a.end() && *it == y) {
        cnt++;
      }
    }
  }
  return cnt;
}
bool is_good_difference(int d, int &first) {
  int y = a[0];
  int cnt = 0;
  auto it = lower_bound(a.begin(), a.end(), y);
  while (it != a.end() && *it == y) {
    y += d;
    if (y >= m) {
      y -= m;
    }
    cnt++;
    it = lower_bound(a.begin(), a.end(), y);
  }
  y = a[0];
  it = lower_bound(a.begin(), a.end(), y);
  while (it != a.end() && *it == y) {
    first = y;
    y -= d;
    if (y < 0) {
      y += m;
    }
    cnt++;
    it = lower_bound(a.begin(), a.end(), y);
  }
  return cnt == n + 1;
}
pair<int, int> solve() {
  if (n == 0) {
    return make_pair(1, 1);
  }
  if (n == 1) {
    return make_pair(a[0], 1);
  }
  sort(a.begin(), a.end());
  int first = 0;
  int difference = a[1] - a[0];
  int k = n - count_differences(difference);
  int d = divide(difference, k, m);
  if (is_good_difference(d, first)) {
    return make_pair(first, d);
  } else {
    return make_pair(-1, -1);
  }
}
int main(int argc, const char *argv[]) {
  int cn = 0;
  vector<int> c;
  pair<int, int> answer(-1, -1);
  cin >> m >> n;
  cn = n;
  c.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  if (n == 1) {
    cout << c[0] << " " << 1 << endl;
    return 0;
  }
  if (2 * n >= m) {
    vector<int> b;
    sort(c.begin(), c.end());
    for (int i = 0; i < m; i++) {
      auto it = lower_bound(c.begin(), c.end(), i);
      if (it == c.end() || *it != i) {
        b.push_back(i);
      }
    }
    n = m - n;
    a = b;
    pair<int, int> now = solve();
    if (now.first > -1) {
      answer.second = now.second;
      answer.first = (now.first + 1LL * n * now.second) % m;
    }
  } else {
    a = c;
    answer = solve();
  }
  if (answer.first == -1) {
    cout << -1 << endl;
  } else {
    cout << answer.first << " " << answer.second << endl;
  }
  return 0;
}
