#include <bits/stdc++.h>
using namespace std;
int a[4], b[310];
int i, k = 0, j, n, c;
set<int> s;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c;
    s.insert(c);
  }
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    a[k++] = *it;
  }
  a[k] = *s.end();
  if (k == 1) cout << "0";
  if (k == 2) {
    i = a[1] - a[0];
    j = (a[0] + a[1]) / 2;
    if (j - a[0] == a[1] - j) i = min(i, j - a[0]);
    printf("%d", i);
  }
  if (k == 3) {
    if (a[1] - a[0] == a[2] - a[1])
      printf("%d", a[1] - a[0]);
    else
      printf("-1");
  }
  if (k > 3) cout << "-1";
  return 0;
}
