#include <bits/stdc++.h>
using namespace std;
int n, a, b, arr[2003];
int main(void) {
  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;
}
