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