#include <bits/stdc++.h>
using namespace std;
int nl[200010];
int link[200010][2];
int main() {
  int n;
  int i;
  int l, r, mid;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &nl[i]);
    link[i][0] = i - 1;
    link[i][1] = i + 1;
  }
  link[n - 1][1] = -1;
  sort(nl, nl + n);
  l = 0;
  r = n - 1;
  mid = (l + r) / 2;
  for (i = 0; i < n - 2; i++) {
    if ((i & 1) == 0) {
      if (nl[mid] - nl[l] <= nl[r] - nl[link[mid][1]]) {
        r = link[r][0];
        link[r][1] = -1;
      } else {
        l = link[l][1];
        link[l][0] = -1;
        mid = link[mid][1];
      }
    } else {
      link[link[mid][0]][1] = link[mid][1];
      link[link[mid][1]][0] = link[mid][0];
      mid = link[mid][0];
    }
  }
  printf("%d\n", nl[r] - nl[l]);
  return 0;
}
