#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(false);
  set<int> bag;
  int n;
  cin >> n;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    bag.insert(x);
  }
  if (bag.size() == 1)
    cout << 0 << '\n';
  else if (bag.size() == 2) {
    int ans = *bag.rbegin() - *bag.begin();
    if (!(ans & 1)) ans /= 2;
    cout << ans << '\n';
  } else if (bag.size() == 3) {
    int a[3];
    int i = 0;
    for (auto z : bag) a[i++] = z;
    if (a[1] - a[0] == a[2] - a[1])
      cout << a[1] - a[0] << '\n';
    else
      cout << -1 << '\n';
  } else
    cout << -1 << '\n';
  return 0;
}
