#include <bits/stdc++.h>
using namespace std;
struct Interval {
  int start, end;
};
bool compare(Interval i1, Interval i2) { return (i1.start < i2.start); }
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  set<int> second;
  for (long long int i = 0; i < (n); ++i) {
    cin >> a[i];
    second.insert(a[i]);
  }
  if (second.size() > 3)
    cout << -1;
  else if (second.size() == 3) {
    vector<long long int> v;
    v.assign(second.begin(), second.end());
    if (v[2] - v[1] == v[1] - v[0])
      cout << v[2] - v[1];
    else
      cout << -1;
  } else if (second.size() == 2) {
    vector<long long int> v;
    v.assign(second.begin(), second.end());
    if (v[0] % 2 == v[1] % 2)
      cout << (v[1] - v[0]) / 2;
    else
      cout << v[1] - v[0];
  } else
    cout << 0;
  return 0;
}
