#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  unordered_map<string, string> mp;
  vector<long long> v;
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    long long p;
    cin >> p;
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  if (v[b - 1] == v[b])
    cout << 0;
  else {
    cout << v[b] - v[b - 1];
  }
  return 0;
}
