#include <bits/stdc++.h>
using namespace std;
bool myfunction(int i, int j) { return (i < j); }
int main() {
  int n, a, b, h;
  cin >> n >> a >> b;
  vector<int> myvector(n);
  for (int i = 0; i < n; ++i) {
    cin >> h;
    myvector.at(i) = h;
  }
  sort(myvector.begin(), myvector.end(), myfunction);
  cout << myvector.at(b) - myvector.at(b - 1) << endl;
  return 0;
}
