#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int arr[n];
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s.insert(arr[i]);
  }
  sort(arr, arr + n);
  int cnt = (arr[b] - arr[--b]);
  cout << cnt;
  return 0;
}
