#include <bits/stdc++.h>
using namespace std;
long long a[400008];
long long yuan[400008];
int vis[100009];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    yuan[i] = a[i];
  }
  sort(yuan + 1, yuan + 1 + n);
  a[0] = 0;
  int le = 1;
  int ri = n;
  int cnt = (n - 2) / 2;
  if (cnt <= 0)
    cout << yuan[n] - yuan[1] << endl;
  else {
    long long minn = 0x3f3f3f3f3f3f3f;
    long long minid;
    for (int i = 1; i + cnt + 1 <= n; i++) {
      long long tem = yuan[i + cnt + 1] - yuan[i];
      if (tem < minn) {
        minn = tem;
        minid = i;
      }
    }
    cout << minn << endl;
  }
}
