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