#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000;
int x[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  sort(x, x + n);
  int k = (n - 2 + 1) / 2;
  int ans = 2 * 1000 * 1000 * 1000;
  for (int l = 0; l <= k; l++) {
    int r = k - l;
    ans = min(ans, x[n - 1 - r] - x[l]);
  }
  cout << ans << endl;
  return 0;
}
