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