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