#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  long long h[2005];
  while (~scanf("%d%d%d", &n, &a, &b)) {
    for (int i = 0; i < n; i++) scanf("%lld", &h[i]);
    sort(h, h + n);
    if (h[b - 1] != h[b])
      printf("%lld\n", h[b] - h[b - 1]);
    else
      printf("%d\n", 0);
  }
  return 0;
}
