#include <bits/stdc++.h>
using namespace std;
inline void optimizeIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const int nmax = 150005;
const long long LINF = 1e17;
int ara[110];
set<int> SET;
int main() {
  optimizeIO();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ara[i];
    SET.insert(ara[i]);
  }
  int siz = SET.size();
  if (siz > 3) {
    cout << -1;
    return 0;
  }
  if (siz == 3) {
    vector<int> v;
    for (auto x : SET) v.push_back(x);
    int a = v[2] - v[1];
    int b = v[1] - v[0];
    if (a != b) {
      cout << -1;
      return 0;
    }
    if (a == b) {
      cout << a << endl;
      return 0;
    }
  }
  if (siz == 2) {
    vector<int> v;
    for (auto x : SET) v.push_back(x);
    int a = v[1] - v[0];
    if (a % 2 == 1) {
      cout << a << endl;
      return 0;
    }
    if (a % 2 == 0) {
      cout << a / 2 << endl;
      return 0;
    }
  }
  if (siz == 1) {
    cout << 0 << endl;
  }
  return 0;
}
