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