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