#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> num;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    num.insert(temp);
  }
  set<int>::iterator it = num.begin();
  vector<int> A;
  for (it = num.begin(); it != num.end(); ++it) {
    A.push_back(*it);
  }
  if (A.size() > 3 || (A.size() == 3 && (A[1] - A[0] != A[2] - A[1]))) {
    cout << -1 << endl;
    return 0;
  }
  if (A.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (A.size() == 2) {
    if ((A[1] - A[0]) % 2 == 0)
      cout << (A[1] - A[0]) / 2 << endl;
    else
      cout << A[1] - A[0] << endl;
    return 0;
  }
  cout << A[1] - A[0] << endl;
  return 0;
}
