#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, k;
  cin >> n >> a >> b;
  int m_prime[n];
  for (int i = 0; i < n; i++) {
    cin >> m_prime[i];
  }
  sort(m_prime, m_prime + n);
  k = abs(m_prime[b - 1] - m_prime[b]);
  cout << k << endl;
}
