#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, f = 1;
  cin >> n;
  vector<long long> v;
  for (long long i = 0; i <= n - 1; i = i + 1) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  long long k = unique(v.begin(), v.end()) - v.begin();
  v.resize(k);
  long long a[k - 1];
  for (long long i = 1; i <= k - 1; i = i + 1) {
    if (i == 1) {
      a[i - 1] = v[i] - v[i - 1];
    } else {
      a[i - 1] = v[i] - v[i - 1];
      if (a[i - 1] != a[i - 2]) f = 0;
    }
  }
  if (k > 3) {
    cout << -1;
  } else {
    if (f == 0)
      cout << -1;
    else {
      if (k == 1) {
        cout << 0;
        return 0;
      }
      if (k == 2) {
        if (a[0] % 2)
          cout << a[0];
        else
          cout << a[0] / 2;
        return 0;
      }
      cout << a[0];
    }
  }
  return 0;
}
