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