#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int* m = new int[n];
  for (a = 0; a < n; a++) cin >> m[a];
  sort(m, m + n);
  cout << m[b] - m[b - 1];
  return 0;
}
