#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> x(n);
  set<int> have_c;
  for (auto &t : x) {
    cin >> t;
    have_c.insert(t);
  }
  sort(x.begin(), x.end());
  int res = 1e9;
  for (int i = 0; i + n / 2 < n; i++) {
    res = min(res, x[i + n / 2] - x[i]);
  }
  cout << res << endl;
}
