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