#include <bits/stdc++.h>
using namespace std;
vector<int> s;
int main() {
  int n, a;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    s.push_back(a);
  }
  sort(s.begin(), s.end());
  int p = n / 2;
  int ans = 0x7fffffff;
  for (int i = 0; i + p < n; i++) {
    ans = min(ans, s[i + p] - s[i]);
  }
  cout << ans << endl;
  return 0;
}
