#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[105];
  int n;
  double ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans = 0;
  sort(a, a + n);
  double sum = a[n - 1] - a[0];
  sum /= 2;
  ans = a[0] + sum;
  int flag = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] + sum == ans || a[i] - sum == ans || a[i] - 0 == ans) {
      flag = 1;
    } else {
      flag = 0;
      break;
    }
  }
  if (flag == 0) {
    cout << "-1" << endl;
  }
  if (flag == 1) {
    if (sum > (int)(a[n - 1] - a[0]) / 2) {
      sum = sum * 2;
    }
    cout << sum << endl;
  }
  return 0;
}
