#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50, INF = 1e9 + 7, EPS = 1e-9;
int a[N];
int main() {
  int n, sum = 0, mi;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int k = n - ((n - 1) / 2 + 1);
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];
  for (int i = 0; i < k; i++) sum += a[i];
  mi = sum;
  for (int i = k; i < n - 1; i++) {
    sum = sum + a[i] - a[i - k];
    mi = min(mi, sum);
  }
  cout << mi;
  return 0;
}
