#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> posSet;
  int m = n / 2;
  for (int i = 0; i < n; i++) {
    int input;
    scanf("%d", &input);
    posSet.insert(input);
  }
  vector<int> pos(posSet.begin(), posSet.end());
  int Min = INT_MAX;
  for (int i = 0; i + m < n; i++) {
    Min = min(pos[i + m] - pos[i], Min);
  }
  cout << Min;
  return 0;
}
