#include <bits/stdc++.h>
using namespace std;
int main() {
  if (0) {
    freopen("CP.inp", "r", stdin);
    freopen("CP.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  if (n == 1) {
    cout << "0\n";
    return 0;
  }
  sort(a.begin(), a.end());
  auto it = unique(a.begin(), a.end());
  a.resize(distance(a.begin(), it));
  if (a.size() > 3) {
    cout << "-1\n";
    return 0;
  } else if (a.size() == 3) {
    cout << (a[1] - a[0] == a[2] - a[1] ? a[1] - a[0] : -1) << '\n';
  } else if (a.size() == 2) {
    cout << ((a[1] - a[0]) % 2 ? a[1] - a[0] : (a[1] - a[0]) / 2) << '\n';
  } else {
    cout << "0\n";
  }
  return 0;
}
