#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> a;
  set<int> s;
  for (int i = 0; i < n; ++i) {
    int num;
    cin >> num;
    s.insert(num);
  }
  if ((int)s.size() == 1)
    cout << 0 << '\n';
  else if ((int)s.size() == 2) {
    for (int num : s) a.push_back(num);
    if ((a[0] & 1) == (a[1] & 1))
      cout << (a[1] - a[0]) / 2 << '\n';
    else
      cout << (a[1] - a[0]) << '\n';
  } else if ((int)s.size() == 3) {
    for (int num : s) a.push_back(num);
    if (a[1] - a[0] != a[2] - a[1])
      cout << -1 << '\n';
    else
      cout << a[1] - a[0] << '\n';
  } else
    cout << -1 << '\n';
  return 0;
}
