#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  if (v.size() > 3) {
    cout << -1;
  } else {
    if (v.size() == 1) {
      cout << 0;
    } else if (v.size() == 2) {
      if ((v[1] - v[0]) % 2 == 0) {
        cout << (v[1] - v[0]) / 2;
      } else {
        cout << v[1] - v[0];
      }
    } else {
      if (v[1] - v[0] != v[2] - v[1]) {
        cout << -1;
      } else {
        cout << v[1] - v[0];
      }
    }
  }
}
