#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int s[105];
  while (cin >> n) {
    int key;
    for (int i = 0; i < n; i++) scanf("%d", &s[i]);
    sort(s, s + n);
    for (int i = 0; i < 100; i++) {
      int ans = s[0] + i;
      key = 1;
      for (int j = 0; j < n; j++) {
        if (s[j] - i == ans || s[j] == ans || s[j] + i == ans)
          continue;
        else {
          key = 0;
          break;
        }
      }
      if (key == 1) {
        cout << i << endl;
        break;
      }
    }
    if (key == 0) cout << "-1" << endl;
  }
  return 0;
}
