#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int n;
vector<int> a;
void input() {
  cin >> n;
  a.resize(n);
  for (auto &i : a) cin >> i;
}
void solve() {
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  if (a.size() > 3)
    cout << -1;
  else {
    if (a.size() == 1)
      cout << 0;
    else if (a.size() == 2) {
      if ((a[1] - a[0]) & 1)
        cout << a[1] - a[0];
      else
        cout << (a[1] - a[0]) / 2;
    } else {
      if (a[1] - a[0] != a[2] - a[1])
        cout << -1;
      else
        cout << a[1] - a[0];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    input();
    solve();
  }
  return 0;
}
