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