#include <bits/stdc++.h>
using namespace std;
int n;
bool f[150];
int a[1000];
int cnt = 0;
int maxx = -1, minn = 200, mid;
int main() {
  memset(f, 0, sizeof(f));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    maxx = max(maxx, a[i]);
    minn = min(minn, a[i]);
    if (!f[a[i]]) {
      cnt++;
      f[a[i]] = 1;
    }
  }
  if (cnt > 3) {
    cout << -1 << endl;
    return 0;
  }
  if (cnt == 3) {
    for (int i = 1; i <= n; i++) {
      if (a[i] != maxx && a[i] != minn) mid = a[i];
    }
    if ((maxx - mid) == (mid - minn)) {
      cout << mid - minn << endl;
      return 0;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (cnt == 2) {
    if ((maxx - minn) % 2 == 0)
      cout << (maxx - minn) / 2 << endl;
    else
      cout << (maxx - minn) << endl;
    return 0;
  }
  if (cnt == 1) {
    cout << 0 << endl;
    return 0;
  }
  return 0;
}
