#include <bits/stdc++.h>
using namespace std;
const long long N = 500010;
const long long INF = 9999999;
long long n, x, y;
long long a[N];
int main() {
  scanf("%lld %lld %lld", &n, &x, &y);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + 1 + n);
  printf("%lld", a[y] - a[1]);
  return 0;
}
