#include <bits/stdc++.h>
using namespace std;
int a[200005], ans;
int main() {
  int i, j, n, m;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  m = n - (n - 1) / 2;
  ans = a[n] - a[1];
  for (i = 1; i + m - 1 <= n; i++) {
    ans = min(ans, a[i + m - 1] - a[i]);
  }
  printf("%I64d\n", ans);
  return 0;
}
