#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * int(1e9);
const long long INFll = 1ll * INF * INF;
const int MOD = 1000000007;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(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 = INF;
  for (int i = n / 2; i < n; ++i) ans = min(ans, a[i] - a[i - n / 2]);
  cout << ans;
  if (0) cerr << "\nTIME = " << clock() << "\n";
  return 0;
}
