#include <bits/stdc++.h>
using namespace std;
const long long N = 3e3 + 7;
long long k[N];
void solve() {
  long long n, a, b;
  cin >> n >> a >> b;
  for (long long i = 1; i <= n; i++) cin >> k[i];
  sort(k + 1, k + n + 1);
  cout << k[n - (a - 1)] - k[n - a];
}
int32_t main() {
  long long t = 1;
  while (t--) solve(), cout << endl;
  return 0;
}
