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