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