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