#include <bits/stdc++.h>
using namespace std;
ifstream in("warrior_and_archer.in");
ofstream out("warrior_and_archer.out");
int main() {
  int n, jum, rez = 1000000000;
  cin.sync_with_stdio(false);
  cin >> n;
  jum = n / 2;
  vector<int> v(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for (int i = 1; i + jum <= n; i++) rez = min(rez, v[i + jum] - v[i]);
  cout << rez;
  return 0;
}
