#include <bits/stdc++.h>
using namespace std;
int main() {
  std::istream_iterator<int> it(cin);
  int n = *it++, a = *it++, b = *it++;
  vector<int> v(n);
  for (int i = 0; i < n; i++) v[i] = *it++;
  sort(v.begin(), v.end());
  cout << v[b] - v[b - 1];
}
