#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(int num, int idx) { return num ^ (1 << idx); }
void FS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int arr[109];
int main() {
  int n;
  cin >> n;
  int mx = 0, mi = 300;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
    mi = min(mi, arr[i]);
  }
  for (int i = 0; i <= 200; i++) {
    bool ok = 1;
    for (int j = 0; j < n && ok; j++) {
      for (int k = j + 1; k < n && ok; k++) {
        int diff = abs(arr[j] - arr[k]);
        if ((i != 0 && diff % i != 0) || (diff != 0 && i == 0)) ok = 0;
      }
    }
    if (ok == 0) continue;
    if (i != 0 && ((mx - mi) / i > 2)) continue;
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1\n";
}
