#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x3f3f3f3f;
int n;
int a[200];
set<int> st;
int main() {
  cin >> n;
  vector<int> b;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    st.insert(a[i]);
  }
  cnt = st.size();
  set<int>::iterator it;
  for (it = st.begin(); it != st.end(); ++it) {
    b.push_back(*it);
  }
  if (cnt > 3) {
    cout << -1 << endl;
  } else if (cnt == 3) {
    sort(b.begin(), b.end());
    int tmp1 = b[1] - b[0];
    int tmp2 = b[2] - b[1];
    if (tmp1 != tmp2)
      cout << -1 << endl;
    else
      cout << tmp1 << endl;
  } else if (cnt == 2) {
    sort(b.begin(), b.end());
    if ((b[1] - b[0]) % 2 == 0)
      cout << (b[1] - b[0]) / 2 << endl;
    else
      cout << (b[1] - b[0]) << endl;
  } else if (cnt == 1)
    cout << 0 << endl;
  return 0;
}
