#include <bits/stdc++.h>
using namespace std;
long long arr[500010];
long long brr[500010];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> s;
  map<int, int> m;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (m[x] == 0) {
      v.push_back(x);
      m[x] = 1;
    }
  }
  sort(v.begin(), v.end());
  if (v.size() == 1) return cout << "0" << endl, 0;
  if (v.size() == 2) {
    int dif = v[1] - v[0];
    if (dif % 2)
      cout << dif << endl;
    else
      cout << dif / 2 << endl;
    return 0;
  }
  if (v.size() > 3) return cout << "-1" << endl, 0;
  int a = v[0], b = v[1], c = v[2];
  int dif1 = b - a;
  int dif2 = c - b;
  if (dif1 == dif2) {
    cout << dif1 << endl;
  } else
    cout << "-1" << endl;
}
