#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:30777216")
using namespace std;
long long n;
vector<long long> p;
int main() {
  long long k, sum = 0, m, ans = 99999999999, x_1, x_2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long cur;
    cin >> cur;
    p.push_back(cur);
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n / 2; i++) {
    ans = min(ans, p[i + n / 2] - p[i]);
  }
  cout << ans;
  return 0;
}
