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