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