#include <bits/stdc++.h>
using namespace std;
int leap[200], a[100], sum;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(leap, 0, sizeof(leap));
    sum = 0;
    memset(a, 0, sizeof(a));
    for (int i = (0); i < (n); ++i) {
      int x;
      scanf("%d", &x);
      if (leap[x] == 0) {
        leap[x]++;
        a[++sum] = x;
      }
    }
    if (sum == 1) {
      printf("0\n");
      continue;
    } else if (sum == 2) {
      int d = 0, mi = 0, ma = 0;
      mi = min(a[1], a[2]);
      ma = max(a[1], a[2]);
      d = ma + mi;
      if (d == ((d / 2) * 2))
        printf("%d\n", ma - d / 2);
      else
        printf("%d\n", ma - mi);
      continue;
    } else if (sum > 3) {
      printf("-1\n");
      continue;
    }
    sort(a + 1, a + sum + 1);
    if (2 * a[2] == a[1] + a[3])
      printf("%d\n", a[3] - a[2]);
    else
      printf("-1\n");
  }
}
