#include <bits/stdc++.h>
using namespace std;
int a[101], b[5];
int main() {
  int n, d, top = 1;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  b[0] = a[0];
  for (int i = 0; i < n - 1; i++)
    if (a[i] != a[i + 1]) b[top++] = a[i + 1];
  if (top <= 1)
    cout << '0' << endl;
  else if (top == 2) {
    d = b[1] - b[0];
    if (d & 1)
      cout << d << endl;
    else
      cout << d / 2 << endl;
  } else if (top == 3) {
    d = b[1] - b[0];
    if (b[2] - b[1] == d)
      cout << d << endl;
    else
      cout << "-1" << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
