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