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