#include <bits/stdc++.h>
using namespace std;
int A[105], cnt, chk[105], N;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (!chk[A[i]]) {
      chk[A[i]] = 1;
      cnt++;
    }
  }
  sort(A + 1, A + 1 + N);
  if (cnt == 1) cout << 0;
  if (cnt == 2) {
    if ((A[1] + A[N]) % 2)
      cout << A[N] - A[1];
    else
      cout << (A[N] - A[1]) / 2;
  }
  if (cnt == 3) {
    if ((A[N] - A[1]) % 2)
      cout << -1;
    else {
      int D = A[N] - A[1];
      if (chk[A[1] + D / 2])
        cout << D / 2;
      else
        cout << -1;
    }
  }
  if (cnt > 3) cout << -1;
}
