#include <bits/stdc++.h>
using namespace std;
int X[] = {1, 0, -1, 0, 1, -1, -1, 1};
int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};
void MN(long long int &a, long long int b) {
  if (a > b) a = b;
}
void MX(long long int &a, long long int b) {
  if (a < b) a = b;
}
void MN(int &a, int b) {
  if (a > b) a = b;
}
void MX(int &a, int b) {
  if (a < b) a = b;
}
void MN(double &a, int b) {
  if (a > b) a = b;
}
void MX(double &a, int b) {
  if (a < b) a = b;
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> seq(n);
  for (int i = 0; i < n; i++) cin >> seq[i];
  sort(seq.begin(), seq.end());
  cout << seq[b] - seq[b - 1] << endl;
  return 0;
}
