#include <bits/stdc++.h>
using namespace std;
const long long INF = (int)1e9 + 70;
const long long MOD = 1e9 + 7;
const int MAXN = 200005;
int a[MAXN];
int b[MAXN];
int main() {
  if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
  int(N);
  scanf("%d", &N);
  for (int i = (0); i < (N); i++) scanf("%d", &(b[i]));
  sort(b, b + N);
  for (int i = (0); i < (N - 1); i++) {
    a[i] = b[i + 1] - b[i];
  }
  N--;
  int m = N / 2;
  int s = 0;
  for (int i = (0); i < (N - m); i++) {
    s += a[i];
  }
  int ans = s;
  for (int d = (1); d < (m + 1); d++) {
    s -= a[d - 1];
    s += a[d + N - m - 1];
    ans = min(ans, s);
  }
  cout << ans << "\n";
  return 0;
}
