#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  n = a.size();
  int ans = oo;
  for (int x = 0; x <= 200; x++) {
    int d = abs(x - a[0]);
    bool fnd = true;
    for (int i = 1; i < n; i++) {
      if (a[i] == x || abs(a[i] - x) == d)
        continue;
      else {
        fnd = false;
        break;
      }
    }
    if (fnd) {
      ans = min(ans, d);
    }
  }
  if (ans == oo)
    printf("-1\n");
  else
    printf("%d\n", ans);
}
