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