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