#include <bits/stdc++.h>
using namespace std;
pair<int, int> solve(int m, vector<int> a) {
  if (a.empty()) return make_pair(0, 1);
  if (a.size() == 1) return make_pair(a[0], 1);
  int n = a.size();
  unordered_set<int> nums;
  for (int i = 0; i < n; i++) {
    nums.insert(a[i]);
  }
  random_shuffle(a.begin(), a.end());
  for (int i = 1; i < n; i++) {
    int diff = a[i] - a[0];
    diff = (diff % m + m) % m;
    int cntUp = 0;
    for (int k = 1;; k++)
      if (nums.count((a[0] + k * (long long)diff) % m))
        cntUp++;
      else
        break;
    int cntDown = 0;
    for (int k = 1;; k++)
      if (nums.count((a[0] + (m - k) * (long long)diff) % m))
        cntDown++;
      else
        break;
    if (cntUp + cntDown + 1 == (int)a.size()) {
      auto answer =
          make_pair((int)((a[0] + (m - cntDown) * (long long)diff) % m), diff);
      return answer;
    }
  }
  cout << -1 << endl;
  exit(0);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m, n;
  cin >> m >> n;
  unordered_set<int> nums;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  pair<int, int> answer;
  if (m > 2 * n) {
    answer = solve(m, a);
  } else {
    vector<char> taken(m, false);
    for (int x : a) taken[x] = true;
    vector<int> b;
    for (int i = 0; i < m; i++)
      if (!taken[i]) b.push_back(i);
    answer = solve(m, b);
    answer.first = (answer.first + answer.second * (long long)b.size()) % m;
  }
  cout << answer.first << " " << answer.second << endl;
  return 0;
}
