#include <bits/stdc++.h>
using namespace std;
const int N = 500500;
const long long M = 1e9 + 7;
int n, a[N], answer = M + M;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  for (int i = 0; i + (n - 2) / 2 + 1 < n; ++i) {
    answer = min(answer, a[i + (n - 2) / 2 + 1] - a[i]);
  }
  printf("%d\n", answer);
  return 0;
}
