#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, g = 0;
  cin >> n;
  long long int a[n], b[n];
  b[0] = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 1; i < n; i++) {
    b[i] = a[i] - a[i - 1];
    if (b[i] != 0) {
      g++;
    }
  }
  if (g > 2) {
    cout << "-1" << endl;
    return 0;
  }
  sort(b, b + n);
  if (b[n - 2] == 0) {
    if (b[n - 1] % 2 == 0) {
      cout << b[n - 1] / 2 << endl;
      return 0;
    } else {
      cout << b[n - 1] << endl;
      return 0;
    }
  }
  long long int sum = b[n - 1];
  for (i = n - 1; i >= 0; i--) {
    if (b[i] != sum && b[i] != 0) {
      break;
    }
  }
  if (i != -1) {
    cout << "-1" << endl;
    return 0;
  } else {
    if (sum % 2 == 0 && g <= 1) {
      cout << sum / 2 << endl;
    } else {
      cout << sum << endl;
    }
  }
}
