#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b, n;
  cin >> n >> a >> b;
  vector<int> A(n);
  for (int &x : A) cin >> x;
  sort(A.begin(), A.end());
  if (A[b] - A[b - 1] == 0) {
    cout << "0\n";
    return;
  }
  cout << A[b] - A[b - 1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
