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