#include <bits/stdc++.h>
using namespace std;
int a[110], b[110], cnt, n;
map<int, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int num;
    scanf("%d", &num);
    if (!mp[num]) {
      mp[num]++;
      b[cnt++] = num;
    }
  }
  sort(b, b + cnt);
  if (cnt == 1)
    printf("0");
  else if (cnt == 2) {
    if (abs(b[1] - b[0]) % 2)
      printf("%d", abs(b[1] - b[0]));
    else
      printf("%d", abs(b[1] - b[0]) / 2);
  } else if (cnt == 3 && ((b[1] - b[0]) == (b[2] - b[1])))
    printf("%d", b[1] - b[0]);
  else
    printf("-1");
  return 0;
}
