#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, mx = 0, k, a[3];
  vector<int> v;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j;
    v.push_back(j);
  }
  sort(v.begin(), v.end());
  j = 0;
  for (i = 0; i < n; i++) {
    while (v[i] == v[i + 1] && i < n - 1) {
      i++;
    }
    if (j == 3) {
      cout << -1 << endl;
      return 0;
    }
    a[j] = v[i];
    j++;
  }
  if (j > 3)
    cout << -1 << endl;
  else if (j == 3) {
    k = a[0] + a[2];
    if (k % 2 == 0) {
      k = k / 2;
      if (a[1] == k)
        cout << a[1] - a[0] << endl;
      else
        cout << -1 << endl;
    } else
      cout << -1 << endl;
  } else if (j == 2) {
    k = a[1] - a[0];
    if (k % 2 == 0) {
      k = k / 2;
      cout << k << endl;
    } else
      cout << a[1] - a[0] << endl;
  } else if (j == 1) {
    cout << 0 << endl;
  }
}
