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