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