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