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