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