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