#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, x;
  scanf("%d %d %d", &n, &a, &b);
  vector<int> A;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    A.push_back(x);
  }
  sort(A.begin(), A.end());
  int low = A[b - 1];
  int high = A[b];
  cout << A[b] - A[b - 1] << endl;
  return 0;
}
