#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  min = a[n / 2] - a[0];
  for (int j = n / 2; j < n; j++) {
    if (min > a[j] - a[j - n / 2]) min = a[j] - a[j - n / 2];
  }
  cout << min;
  return 0;
}
