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