#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  v.resize((unique(v.begin(), v.end()) - v.begin()));
  if (v.size() == 1)
    cout << 0 << "\n";
  else if (v.size() > 3)
    cout << -1 << "\n";
  else if (v.size() == 3) {
    if (v[2] - v[1] == v[1] - v[0])
      cout << v[1] - v[0] << "\n";
    else
      cout << -1 << "\n";
  } else {
    int dif = v[1] - v[0];
    cout << ((dif & 1) ? dif : dif / 2) << "\n";
  }
  return 0;
}
