#include <bits/stdc++.h>
using namespace std;
const int nn = 105;
int arr[nn], frek[nn];
int main() {
  int n, ragam = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    if (frek[arr[i]] == 0) ragam++;
    frek[arr[i]]++;
  }
  if (ragam > 3)
    printf("-1\n");
  else if (ragam == 1)
    printf("0\n");
  else if (ragam == 2) {
    int kiri = -1, kanan;
    for (int i = 1; i <= 100; i++) {
      if (frek[i] > 0) {
        if (kiri == -1)
          kiri = i;
        else
          kanan = i;
      }
    }
    if ((kiri + kanan) % 2 == 0)
      printf("%d\n", (kiri + kanan) / 2 - kiri);
    else
      printf("%d\n", kanan - kiri);
  } else {
    int kiri = -1, tengah = -1, kanan;
    for (int i = 1; i <= 100; i++) {
      if (frek[i] > 0) {
        if (kiri == -1)
          kiri = i;
        else if (tengah == -1)
          tengah = i;
        else
          kanan = i;
      }
    }
    if ((kiri + kanan) / 2 == tengah && (kiri + kanan) % 2 == 0)
      printf("%d\n", tengah - kiri);
    else
      printf("-1\n");
  }
}
