#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  long long a[n];
  long long co[101] = {0};
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    co[a[i] - 1]++;
  }
  long long c = 0;
  for (long long i = 0; i < 101; i++) {
    if (co[i] != 0) {
      c++;
      v.push_back(i + 1);
    }
  }
  if (c > 3)
    cout << -1 << "\n";
  else if (c == 1)
    cout << 0 << "\n";
  else {
    if (c == 2) {
      if ((v[0] + v[1]) % 2 == 0)
        cout << (v[0] + v[1]) / 2 - v[0] << "\n";
      else
        cout << v[1] - v[0] << "\n";
    } else {
      if ((v[0] + v[2]) % 2 == 0 && (v[0] + v[2]) / 2 == v[1])
        cout << v[1] - v[0] << "\n";
      else
        cout << -1 << "\n";
    }
  }
  return 0;
}
