#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, aa[100], i, s, bb[100], j = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> aa[i];
  }
  sort(aa, aa + n);
  bb[j++] = aa[0];
  for (i = 1; i < n; i++) {
    if (aa[i] != aa[i - 1]) {
      bb[j++] = aa[i];
    }
  }
  if (j > 3) {
    cout << "-1";
  } else if (j == 2) {
    if ((bb[1] - bb[0]) % 2 != 0) {
      cout << bb[1] - bb[0];
    } else
      cout << (bb[1] - bb[0]) / 2;
  } else if (j == 1) {
    cout << "0";
  } else {
    sort(bb, bb + j);
    if ((bb[j - 1] - bb[j - 2]) == (bb[1] - bb[0]))
      cout << bb[1] - bb[0];
    else
      cout << "-1";
  }
  return 0;
}
