#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  int cnt = 0;
  int front = 0;
  int mid = 0;
  int last = 0;
  for (int i = 1; i <= 100; i++) {
    if (a[i] > 0) cnt++;
    if (cnt == 1 && front == 0) front = i;
    if (cnt == 2 && mid == 0) mid = i;
    if (cnt == 3 && last == 0) last = i;
  }
  if (cnt > 3)
    cout << -1;
  else if (cnt == 1)
    cout << 0;
  else if (cnt == 2 && (mid - front) % 2 == 0)
    cout << (mid - front) / 2;
  else if (cnt == 2)
    cout << (mid - front);
  else if (last - mid == mid - front)
    cout << last - mid;
  else
    cout << -1;
  return 0;
}
