#include <bits/stdc++.h>
using namespace std;
long long a[555555], n;
long long fir(long long i, long long j) { return abs(a[n - j - 1] - a[i]); }
long long sec(long long i, long long j) { return (a[n - i - 1] - a[j]); }
int main() {
  long long s = 0, i, j, k, l, m, t, f = 0, z = 0, ans;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long long rem = (n + 1) / 2 - 1;
  ans = a[n - 1] - a[0];
  for (i = 0; i <= rem; ++i) {
    ans = min(ans, fir(rem - i, i));
  }
  cout << ans;
  return 0;
}
