#include <bits/stdc++.h>
using namespace std;
int i, j, n, a[105], b[105];
int main() {
  for (cin >> n; i < n;) cin >> a[i++];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] ^ a[i + 1]) b[j++] = a[i];
  }
  if (j > 3)
    cout << -1;
  else if (j < 2)
    cout << 0;
  else if (j < 3)
    cout << (b[1] - *b) / (b[1] - *b & 1 ? 1 : 2);
  else
    cout << (b[2] - b[1] ^ b[1] - *b ? -1 : b[1] - *b);
}
