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