#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
void solve() {
  long long n, i, j;
  cin >> n;
  long long a[n], mx = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  long long ans = INT_MAX, flg = 0;
  for (i = 1; i <= mx; i++) {
    set<long long> s;
    for (j = 0; j < n; j++) {
      if (a[j] != i) s.insert(abs(a[j] - i));
    }
    if (s.size() == 1) {
      ans = min(ans, *(s.begin()));
      flg = 1;
    } else if (s.size() == 0) {
      ans = 0;
      flg = 1;
    }
  }
  if (flg == 0) {
    cout << -1;
  } else {
    cout << ans;
  }
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long t = 1, i;
  for (i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
