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