#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5) + 23;
int x[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  sort(x + 1, x + n + 1);
  int v = (n - 2) / 2 + 1;
  int ans = x[v + 1] - x[1];
  for (int i = 2; i + v <= n; i++) {
    ans = min(ans, x[i + v] - x[i]);
  }
  cout << ans;
  return 0;
}
