#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  vector<int> b;
  for (i = 0; i < n; i++) {
    int a;
    cin >> a;
    int sw = 1;
    for (int j = 0; j < b.size(); j++) {
      if (b[j] == a) {
        sw = 0;
        break;
      }
    }
    if (sw) b.push_back(a);
    if (b.size() > 3) {
      cout << -1;
      return 0;
    }
  }
  sort(b.begin(), b.end());
  if (b.size() == 1) {
    cout << 0;
    return 0;
  }
  if (b.size() == 2) {
    cout << (((b[1] - b[0]) % 2 == 0) ? (b[1] - b[0]) / 2 : b[1] - b[0]);
    return 0;
  }
  int dif = b[2] - b[1];
  if (dif == b[1] - b[0])
    cout << dif;
  else
    cout << -1;
  return 0;
}
