#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first - a.second < b.first - b.second == 0) return a.first < b.first;
  return a.first - a.second < b.first - b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  unsigned long long L = 1;
  for (unsigned long long T = 1; T <= L; T++) {
    long long n;
    cin >> n;
    vector<long long> v;
    set<long long> P;
    for (long long i = 0; i < n; i++) {
      long long x;
      cin >> x;
      v.push_back(x);
      P.insert(x);
    }
    if (P.size() > 3) {
      cout << -1 << "\n";
      return 0;
    }
    sort(v.begin(), v.end());
    set<long long> dif;
    for (long long i = 1; i < n; i++) {
      dif.insert(abs(v[i] - v[i - 1]));
    }
    if (dif.size() > 2)
      cout << -1 << "\n";
    else {
      if (dif.size() == 2 && dif.find(0) == dif.end()) {
        cout << -1 << "\n";
      } else {
        vector<long long> B;
        for (auto i : P) {
          B.push_back(i);
        }
        if (B.size() == 1) {
          cout << 0 << "\n";
        } else if (B.size() == 3)
          cout << B[2] - B[1] << "\n";
        else {
          if ((B[1] - B[0]) % 2 == 0)
            cout << (B[1] - B[0]) / 2;
          else
            cout << B[1] - B[0] << "\n";
        }
      }
    }
  }
  return 0;
}
