#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int pos[n];
  for (int i = 0; i < n; i++) {
    cin >> pos[i];
  }
  sort(pos, pos + n);
  int fi = 0;
  int li = n - 1;
  n--;
  n /= 2;
  int bv = pos[li] - pos[fi];
  for (int i = 0; i <= n; i++) {
    bv = min(bv, pos[li - i] - pos[fi + n - i]);
  }
  cout << bv << endl;
  cin >> n;
}
