#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
inline void solve() {
  map<long long, long long> cnt;
  long long n, ans = 0;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  if ((long long)cnt.size() > 3) {
    cout << "-1" << '\n';
    return;
  }
  long long b[3], i = 0;
  for (auto &it : cnt) b[i++] = it.first;
  if (i == 2) {
    if ((b[1] - b[0]) & 1)
      ans = b[1] - b[0];
    else
      ans = (b[1] - b[0]) / 2;
  }
  if (i == 3) {
    ans = b[2] - b[1];
    if (b[2] - b[1] != b[1] - b[0]) ans = -1;
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n = 1;
  while (n--) solve();
  return 0;
}
