#include <bits/stdc++.h>
using namespace std;
int n, a[300000], l, r, ans, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  ans = 2000000000;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (n == 2) {
    cout << a[1] - a[0];
    return 0;
  }
  m = n - 2 - ((n - 3) / 2 + 1) + 1;
  for (int i = 0; i + m < n; i++) ans = min(ans, a[i + m] - a[i]);
  cout << ans;
}
