#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[105];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if ((a[n - 1] - a[0]) % 2 != 0) {
    bool resflag = true;
    for (int i = 0; i < n; i++) {
      if (a[i] != a[n - 1] && a[i] != a[0]) {
        resflag = false;
        break;
      }
    }
    if (resflag)
      cout << a[n - 1] - a[0] << endl;
    else
      cout << -1 << endl;
  } else {
    bool resflag = true;
    int mid = (a[0] + a[n - 1]) / 2;
    for (int i = 0; i < n; i++) {
      if (a[i] != a[n - 1] && a[i] != a[0] && a[i] != mid) {
        resflag = false;
        break;
      }
    }
    if (resflag)
      cout << mid - a[0] << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
