#include <bits/stdc++.h>
int numcmp(const void *p1, const void *p2) {
  int a1 = *(int *)p1, a2 = *(int *)p2;
  return a1 >= a2 ? (a1 > a2 ? -1 : 0) : 1;
}
int main(void) {
  int k, n, a, b, *chore;
  scanf("%d %d %d", &n, &a, &b);
  chore = (int *)malloc(n * sizeof(int));
  for (k = 0; k < n; k++) scanf("%d", chore + k);
  qsort((void *)chore, n, sizeof(int), numcmp);
  printf("%d\n", chore[a - 1] - chore[a]);
  return 0;
}
