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