#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  sort(v.begin(), v.end());
  n = unique(v.begin(), v.end()) - v.begin();
  if (n > 3) {
    printf("-1\n");
  } else {
    if (n == 1)
      printf("0\n");
    else if (n == 2)
      printf("%d\n", (v[1] - v[0]) % 2 == 0 ? (v[1] - v[0]) / 2 : v[1] - v[0]);
    else if (v[1] - v[0] == v[2] - v[1])
      printf("%d\n", v[1] - v[0]);
    else
      printf("-1\n");
  }
  return 0;
}
