#include <bits/stdc++.h>
using namespace std;
long long int a[102];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int b;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> b;
    a[b]++;
    if (a[b] == 1) v.push_back(b);
  }
  sort(v.begin(), v.end());
  if (v.size() > 3) {
    cout << -1 << endl;
  } else if (v.size() == 1) {
    cout << 0 << endl;
  } else if (v.size() == 2) {
    long long int p = v[0];
    long long int q = v[1];
    long long int d = abs(p - q);
    if (d % 2 == 0) d = d / 2;
    cout << d << endl;
  } else if (v.size() == 3) {
    long long int p = v[0];
    long long int q = v[1];
    long long int r = v[2];
    if (abs(p - q) == abs(q - r))
      cout << abs(p - q) << endl;
    else
      cout << -1 << endl;
  }
}
