#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[105];
  int b[105];
  int t, flag, flag1, i, n, c, sum1, sum2;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[a[i]] = 1;
  }
  int count = 0;
  int sum = 0;
  flag = 1;
  int d = -1;
  c = 0;
  for (i = 1; i <= 100; i++) {
    if (b[i] == 1) {
      count++;
      sum += i;
      if (c == 0)
        c = i;
      else {
        if (d == -1) {
          d = i - c;
          c = i;
        } else {
          if (d != i - c) {
            flag = 0;
            break;
          }
          c = i;
        }
      }
    }
  }
  if (flag == 0) {
    printf("-1\n");
  } else if (count == 1) {
    printf("0\n");
  } else if (count == 2) {
    if (sum % 2 == 0) {
      sum = sum / 2;
      printf("%d\n", c - sum);
    } else {
      sum1 = sum - c;
      sum1 = c - sum1;
      sum2 = 2 * c - sum;
      if (sum1 > sum2) {
        sum1 = sum2;
      }
      printf("%d", sum1);
    }
  } else if (count == 3) {
    sum = sum / count;
    printf("%d\n", c - sum);
  } else {
    printf("-1\n");
  }
  return 0;
}
