#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int temp;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    a.push_back(temp);
  }
  sort(a.begin(), a.end());
  auto ip = unique(a.begin(), a.end());
  if (ip - a.begin() > 3) {
    cout << -1;
    return 0;
  }
  if (ip - a.begin() == 1) {
    cout << 0;
    return 0;
  } else if (ip - a.begin() == 2) {
    if ((*(a.begin() + 1) - *a.begin()) % 2 == 0) {
      cout << (*(a.begin() + 1) - *a.begin()) / 2;
    } else
      cout << (*(a.begin() + 1) - *a.begin());
  } else {
    if (*(a.begin() + 1) - *a.begin() == *(a.begin() + 2) - *(a.begin() + 1))
      cout << *(a.begin() + 1) - *a.begin();
    else
      cout << -1;
  }
  return 0;
}
