#include <bits/stdc++.h>
using namespace std;
int a[105];
vector<int> v;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i + 1]) {
      v.push_back(a[i]);
    }
  }
  if (v.size() > 3) {
    cout << "-1";
    return 0;
  }
  if (v.size() == 3) {
    int dif = v[1] - v[0];
    if (v[2] - dif != v[1]) {
      cout << -1;
      return 0;
    }
    cout << dif;
  } else if (v.size() == 2) {
    int dif = v[1] - v[0];
    if (dif % 2 == 0)
      cout << dif / 2;
    else
      cout << dif;
  } else if (v.size() == 1)
    cout << 0;
}
