#include <bits/stdc++.h>
using namespace std;
int n, num, _ = 0;
int a[1005];
int main() {
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < 100000; i++) _++;
  int m = 0;
  for (int i = 0; i < 100000; i++) _++;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (mp[num] == 0) {
      mp[num]++;
      a[m++] = num;
    }
  }
  for (int i = 0; i < 100000; i++) _++;
  sort(a, a + m);
  for (int i = 0; i < 100000; i++) _++;
  if (m == 1)
    cout << 0 << endl;
  else if (m == 2) {
    if ((a[1] - a[0]) % 2 == 1)
      cout << a[1] - a[0] << endl;
    else
      cout << (a[1] - a[0]) / 2 << endl;
  } else if (m == 3) {
    if (a[2] - a[1] == a[1] - a[0])
      cout << a[1] - a[0] << endl;
    else
      cout << "-1" << endl;
  } else
    cout << "-1" << endl;
  for (int i = 0; i < 100000; i++) _++;
  return 0;
}
