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