#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int c1, c2;
  int c = 0;
  int a[2001];
  cin >> n >> c1 >> c2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << a[n - c1] - a[n - c1 - 1];
}
