#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  for (int h = 0; h < n; h++) scanf("%d", &arr[h]);
  sort(arr, arr + n);
  int r = (n - 2) / 2;
  int i = 0, j = n - 1;
  int diff = arr[j] - arr[i];
  diff = min(diff, (arr[j] - arr[i + r]));
  diff = min(diff, (arr[j - r] - arr[i]));
  diff = min(diff, (arr[j - (r / 2)] - arr[i + (r / 2)]));
  for (int e = 0; e <= r; e++) diff = min(diff, arr[j - e] - arr[i + (r - e)]);
  cout << diff << endl;
  return 0;
}
