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