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