#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = a.back() - a[0];
  int eachCanRemove = (n - 2) / 2;
  for (int i = 0; i + eachCanRemove + 1 < n; ++i) {
    ans = min(ans, a[i + eachCanRemove + 1] - a[i]);
  }
  cout << ans << "\n";
  return 0;
}
