#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag = 0;
  cin >> n;
  int a[n], min1 = 200, max1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    max1 = max(max1, a[i]);
    min1 = min(min1, a[i]);
  }
  if ((max1 + min1) % 2 == 0) {
    int avg = (max1 + min1) / 2;
    for (int i = 0; i < n; i++) {
      if (a[i] != avg && a[i] != max1 && a[i] != min1) {
        cout << -1;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << max1 - avg;
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (a[i] != max1 && a[i] != min1) {
        cout << -1;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << max1 - min1;
    }
  }
  return 0;
}
