#include <bits/stdc++.h>
using namespace std;
const int maxn = 102;
int ar[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  int aux;
  bool flag;
  for (int d = 0; d <= 100; d++) {
    flag = 1;
    aux = ar[1];
    for (int i = 2; i <= n && flag; i++) {
      if (ar[i] + d != aux && ar[i] - d != aux && ar[i] != aux) flag = 0;
    }
    if (flag) {
      cout << d << "\n";
      return 0;
    }
    flag = 1;
    aux = ar[1] + d;
    for (int i = 2; i <= n && flag; i++) {
      if (ar[i] + d != aux && ar[i] - d != aux && ar[i] != aux) flag = 0;
    }
    if (flag) {
      cout << d << "\n";
      return 0;
    }
    flag = 1;
    aux = ar[1] - d;
    for (int i = 2; i <= n && flag; i++) {
      if (ar[i] + d != aux && ar[i] - d != aux && ar[i] != aux) flag = 0;
    }
    if (flag) {
      cout << d << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}
