#include <bits/stdc++.h>
const int nmax = 2100;
using namespace std;
int main() {
  int n, a, b, tmp;
  int f[nmax];
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    f[i] = tmp;
  }
  sort(f, f + n);
  b = b - 1;
  if (f[b] == f[b + 1]) {
    cout << 0 << endl;
  } else {
    cout << f[b + 1] - f[b] << endl;
  }
  return 0;
}
