#include <bits/stdc++.h>
using namespace std;
int n, a[110];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  bool zero = true;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[1])
      continue;
    else
      zero = false;
  }
  if (zero) {
    return 0 * puts("0");
  }
  int ans = 110;
  for (int i = 1; i <= 100; i++) {
    for (int k = 1; k <= n; k++) {
      int temp = abs(a[k] - i);
      bool flag = true;
      for (int j = 1; j <= n; j++) {
        if (j == k) continue;
        if ((abs(a[j] - i) == temp) || (abs(a[j] - i) == 0)) {
          continue;
        } else {
          flag = false;
        }
      }
      if (flag) {
        ans = min(ans, temp);
      }
    }
  }
  if (ans == 110)
    puts("-1");
  else
    printf("%d\n", ans);
}
