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