#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  set<int>::iterator it, it1, it2;
  it = s.begin();
  it1 = it;
  it1++;
  it2 = s.end();
  it2--;
  if (s.size() == 1)
    cout << 0 << endl;
  else if (s.size() == 2) {
    int e = *it1 - (*it);
    if (e % 2 == 0) e /= 2;
    cout << e;
  } else if (s.size() == 3) {
    int a = (*it);
    int b = (*it1);
    int c = (*it2);
    if (b - a == c - b)
      cout << b - a << endl;
    else
      cout << -1 << endl;
  } else
    cout << -1 << endl;
}
