#include <bits/stdc++.h>
using namespace std;
int main() {
  int D, n, x, a[105], i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  D = a[n] - a[1];
  if (D % 2 == 1) {
    x = a[n];
    i = 1;
    while (i <= n, (a[i] == x) || (a[i] + D == x)) i++;
    if (i > n)
      cout << D;
    else
      cout << -1;
  } else {
    D = D / 2;
    x = a[n] - D;
    i = 1;
    while (i <= n, (a[i] == x) || (a[i] - D == x) || (a[i] + D == x)) i++;
    if (i > n)
      cout << D;
    else
      cout << -1;
  }
}
