#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, v;
  vector<int> n;
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) {
    cin >> v;
    n.push_back(v);
  }
  sort(n.begin(), n.end());
  cout << n[B] - n[B - 1] << endl;
  return 0;
}
