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