#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int m = b;
  vector<int> v(n), petyas(a), vasya(b);
  for (auto &x : v) cin >> x;
  sort(v.begin(), v.end());
  cout << v[b] - v[b - 1] << "\n";
  return 0;
}
