#include <bits/stdc++.h>
using namespace std;
long int temp, i, j, k, T;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int h[2007];
  for (i = 0; i < n; i++) cin >> h[i];
  sort(h, h + n);
  int val = h[b - 1];
  if (h[b] == val)
    cout << "0" << endl;
  else
    cout << h[b] - val << endl;
  return 0;
}
