#include <bits/stdc++.h>
using namespace std;
int x[3000000];
int main() {
  int n, mn = 1000000000;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  sort(x + 1, x + n + 1);
  for (int i = 1; i + n / 2 <= n; i++) {
    mn = min(mn, x[i + n / 2] - x[i]);
  }
  cout << mn;
  return 0;
}
