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