#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, j;
  cin >> n;
  vector<long long int> a(n);
  for (i = 0; i < n; i++) cin >> a[i];
  long long int ans = INT_MAX;
  long long int min1 = *min_element(a.begin(), a.end());
  long long int max1 = *max_element(a.begin(), a.end());
  for (i = min1; i <= max1; i++) {
    long long int flag = 0;
    long long int d = -1;
    for (j = 0; j < n; j++) {
      if (abs(a[j] - i) == 0 || abs(a[j] - i) == d) {
        continue;
      } else if (d == -1) {
        d = abs(a[j] - i);
      } else if (d != abs(a[j] - i)) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      if (d != -1)
        ans = min(ans, d);
      else
        ans = 0;
    }
  }
  if (ans != INT_MAX) {
    cout << ans;
  } else
    cout << "-1";
}
