#include <bits/stdc++.h>
using namespace std;
int n, x[200005];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  sort(x + 1, x + n + 1);
  int ans = x[n] - x[1];
  for (int i = 1; i <= n >> 1; ++i) ans = min(ans, x[i + (n >> 1)] - x[i]);
  cout << ans << endl;
  return 0;
}
