#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[101], dif[100], i, unique[101], c = 0;
  int min = 0, n, dif1, dif2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  unique[c] = a[0];
  c++;
  for (i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      unique[c] = a[i];
      c++;
    }
  }
  if (c >= 4) {
    cout << -1;
  } else if (c == 1) {
    cout << 0 << endl;
  } else if (c == 2) {
    if ((unique[1] - unique[0]) % 2) {
      cout << unique[1] - unique[0];
    } else {
      cout << (unique[1] - unique[0]) / 2;
    }
  } else {
    if (unique[2] - unique[1] == unique[1] - unique[0]) {
      cout << unique[2] - unique[1];
    } else {
      cout << -1 << endl;
    }
  }
}
