#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
struct Y {
  int fir, sec;
};
bool cmp(Y i, Y j) {
  if (i.fir != j.fir) return i.fir < j.fir;
  return i.sec < j.sec;
}
int main() {
  int A[3001], n, a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  cout << A[n - a] - A[n - a - 1] << endl;
  return 0;
}
