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