#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  long long int arr[100];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  if (n == 1) {
    cout << "0";
    exit(0);
  }
  int min = INT_MAX;
  int max = INT_MIN;
  for (int i = 0; i < n; ++i) {
    if (arr[i] < min) min = arr[i];
    if (arr[i] > max) max = arr[i];
  }
  int temp1 = min % 2;
  int temp2 = max % 2;
  int ans;
  if (temp1 != temp2) {
    ans = (max - min);
  } else {
    ans = (max - min) / 2;
  }
  int answer = min + ans;
  for (int i = 0; i < (n); ++i) {
    if (arr[i] != answer) {
      if ((arr[i] + ans) != answer) {
        if ((arr[i] - ans) != answer) {
          ans = -1;
          break;
        }
      }
    }
  }
  ans = ans >= 0 ? ans : -1;
  cout << ans;
  return 0;
}
