#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, s;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  sort(x.begin(), x.end());
  k = n / 2;
  s = x[k] - x[0];
  for (int i = 1; i < n - k; i++) {
    s = min(s, x[k + i] - x[i]);
  }
  cout << s;
  return 0;
}
