#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[105] = {}, i, temp, num = 0;
  cin >> n;
  int b[n];
  for (i = 0; i < n; i++) {
    cin >> temp;
    a[temp]++;
  }
  for (i = 1; i <= 100; i++) {
    if (a[i] > 0) {
      num++;
      b[num] = i;
    }
  }
  if (num > 3)
    cout << "-1" << endl;
  else {
    if (num == 1)
      cout << "0" << endl;
    else if (num == 2) {
      if ((b[2] + b[1]) % 2)
        cout << b[2] - b[1] << endl;
      else
        cout << ((b[2] + b[1]) / 2) - b[1] << endl;
    } else if (b[2] - b[1] == b[3] - b[2])
      cout << b[2] - b[1] << endl;
    else
      cout << "-1" << endl;
  }
  return 0;
}
