#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, INF = 1e18, MAXN = 1e2 + 10;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, a[MAXN];
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long d = 0; d <= 200; d++) {
    long long X = a[0] - d, f = 1;
    for (long long i = 1; i < n; i++) {
      if (a[i] != X) {
        if (!(a[i] + d == X || a[i] - d == X)) {
          f = 0;
        }
      }
    }
    if (f) {
      cout << d;
      return 0;
    }
    X = a[0] + d;
    f = 1;
    for (long long i = 1; i < n; i++) {
      if (a[i] != X) {
        if (!(a[i] + d == X || a[i] - d == X)) {
          f = 0;
        }
      }
    }
    if (f) {
      cout << d;
      return 0;
    }
    X = a[0];
    f = 1;
    for (long long i = 1; i < n; i++) {
      if (a[i] != X) {
        if (!(a[i] + d == X || a[i] - d == X)) {
          f = 0;
        }
      }
    }
    if (f) {
      cout << d;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
