#include <bits/stdc++.h>
using namespace std;
long long int modexp(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long int a[200005];
vector<long long int> vt;
int main() {
  int n, i, j, k, l;
  long long int mv, cur;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (i = 1; i < n; ++i) vt.push_back(a[i] - a[i - 1]);
  k = (n - 2) / 2;
  l = vt.size() - k;
  for (i = mv = 0; i < l; ++i) mv += vt[i];
  cur = mv;
  for (i = 1; i < vt.size(); ++i) {
    if (i + l > vt.size()) break;
    cur += vt[i + l - 1];
    cur -= vt[i - 1];
    mv = min(cur, mv);
  }
  cout << mv << endl;
  return 0;
}
