#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
int n, a[N], b[N], tmp[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int m = unique(a + 1, a + n + 1) - (a + 1);
  int ans = 0x3f3f3f3f;
  for (int lst = 0; lst <= 200; lst++) {
    int f = 1, D = 0;
    for (int i = 1; i <= n; i++)
      if (a[i] != lst) D = abs(a[i] - lst);
    for (int i = 1; i <= n; i++) {
      if (a[i] != lst && a[i] - D != lst && a[i] + D != lst) {
        f = 0;
        break;
      }
    }
    if (f) ans = min(ans, D);
  }
  if (ans == 0x3f3f3f3f)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
