#include <bits/stdc++.h>
using namespace std;
int isP(long int hj) {
  long int op;
  for (op = 2; op <= sqrt(hj); op++) {
    if (hj % op == 0) return 0;
  }
  return 1;
}
int main() {
  long long int c, s, sm1, sm2, sm3, sr, sl, l, ln, rz, rn, car, ch, eq, r, shr,
      ng, d, v, curr, spl, fl, z, ev, od, t, m, ct, j, q, k, b, maxI, max1,
      max2, lt, md, prev, a, f, n, xP, xN, w, h, d2, d1, u1, u2, sm, i, p, x, y;
  cin >> n >> a >> b;
  long int A[n];
  for (i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A, A + n);
  cout << A[n - a] - A[n - a - 1];
  return 0;
}
