#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int A[3000], n;
int main() {
  int i, j, a, b;
  scanf("%d %d %d", &n, &a, &b);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  sort(A, A + n);
  printf("%d\n", A[n - a] - A[n - a - 1]);
}
