#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
const long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(12);
  cout << fixed;
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  sort(x.begin(), x.end());
  int res = 1e9 + 7;
  for (int i = 0; i + n / 2 < n; ++i) res = min(res, x[i + n / 2] - x[i]);
  cout << res << '\n';
  return 0;
}
