#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(12);
  ;
  long long w;
  cin >> w;
  vector<long long> s;
  set<long long> se;
  while (w--) {
    long long temp;
    cin >> temp;
    s.push_back(temp);
  }
  sort(s.begin(), s.end());
  for (long long i = 0; i < s.size(); i++) {
    se.insert(s[i]);
  }
  set<long long>::iterator it, it1, t, t1, t2, t3;
  it = se.begin();
  if (se.size() == 1)
    cout << "0";
  else if (se.size() == 2) {
    long long k = abs(*it - *(++it));
    if (k % 2)
      cout << k;
    else
      cout << k / 2;
  } else if (se.size() == 3) {
    it = se.begin();
    long long output;
    t1 = it;
    t2 = ++it;
    t3 = ++it;
    it = t1;
    it++;
    if ((*t2 - *t1) == (*t3 - *t2))
      cout << abs(*it - *(++it));
    else {
      cout << -1;
    }
  } else
    cout << -1;
}
