#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long powmod(long long a, long long b, long long m) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return (b > 0 ? gcd(b, a % b) : a); }
const int N = (int)5e5 + 5;
const int mod = (int)1e9 + 7;
const long long inf = (long long)1e18 + 18;
int n, a[N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int ans = a[n] - a[1];
  for (int i = 1; i <= n / 2; i++) {
    ans = min(ans, a[i + n / 2] - a[i]);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tt = 1;
  while (tt--) solve();
  return 0;
}
