#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> a;
  int n, b, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b;
    a.insert(b);
  }
  if (a.size() == 1)
    std::cout << 0 << endl;
  else if (a.size() == 2) {
    b = *a.begin();
    c = *(--a.end());
    int a1;
    if ((c - b) % 2 == 1)
      a1 = c - b;
    else
      a1 = (c - b) / 2;
    cout << a1 << endl;
  } else if (a.size() == 3) {
    auto iter = a.begin();
    int a1, a2, a3;
    a1 = *iter++;
    a2 = *iter++;
    a3 = *iter;
    if (a2 - a1 == a3 - a2)
      cout << a2 - a1 << endl;
    else
      cout << -1 << endl;
  } else
    cout << -1 << endl;
  return 0;
}
