#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) { return (a > b) ? b : a; }
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n + 1, 0);
  int _n = n / 2;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin() + 1, a.end());
  int res = 1e9;
  for (int i = 1; i + _n <= n; i++) {
    res = min(res, a[i + _n] - a[i]);
  }
  printf("%d", res);
}
