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