#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int main() {
  cin >> n >> a >> b;
  long long chores[n];
  for (int i = 0; i < n; i++) cin >> chores[i];
  sort(chores, chores + n);
  cout << chores[b] - chores[b - 1] << endl;
  return 0;
}
