#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, k;
  cin >> n >> a >> b;
  int arr1[n];
  for (int i = 0; i < n; i++) cin >> arr1[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (arr1[i] > arr1[j]) {
        int t = arr1[j];
        arr1[j] = arr1[i];
        arr1[i] = t;
      }
    }
  }
  int arr2[b];
  for (int i = 0; i < b + 1; i++) arr2[i] = arr1[i];
  k = arr2[b] - arr2[b - 1];
  cout << k << endl;
  return 0;
}
