#include <bits/stdc++.h>
int ac[2005];
int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (register int i = 1; i <= n; i++) scanf("%d", &ac[i]);
  std::sort(ac + 1, ac + n + 1);
  printf("%d\n", ac[b + 1] - ac[b]);
  return 0;
}
