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