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