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