#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 1;
inline long long input(void) {
  char t;
  long long x = 0;
  int neg = 0;
  t = getchar();
  while ((t < 48 || t > 57) && t != '-') t = getchar();
  if (t == '-') {
    neg = 1;
    t = getchar();
  }
  while (t >= 48 && t <= 57) {
    x = (x << 3) + (x << 1) + t - 48;
    t = getchar();
  }
  if (neg) x = -x;
  return x;
}
inline void output(long long x) {
  char a[20];
  int i = 0, j;
  a[0] = '0';
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x == 0) putchar('0');
  while (x) {
    a[i++] = x % 10 + 48;
    x /= 10;
  }
  for (j = i - 1; j >= 0; j--) {
    putchar(a[j]);
  }
  putchar('\n');
}
int main() {
  long long n, i, a[200010], x[200010], sum, min = 1e9;
  n = input();
  for (int i = 0; i < n; ++i) a[i] = input();
  sort(a, a + n);
  for (int i = 0; i < n - 1; ++i) x[i] = a[i + 1] - a[i];
  sum = 0;
  for (int i = 0; i < n / 2; ++i) sum += x[i];
  min = sum;
  for (int i = n / 2; i < n - 1; ++i) {
    sum = sum + x[i] - x[i - n / 2];
    if (sum < min) min = sum;
  }
  output(min);
  return 0;
}
