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