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