#include <bits/stdc++.h>
using namespace std;
int MAX(int a, int b) { return (a > b) ? a : b; }
double MAX(double a, double b) { return (a > b) ? a : b; }
int MIN(int a, int b) { return (a < b) ? a : b; }
double MIN(double a, double b) { return (a < b) ? a : b; }
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int GCD(unsigned long long int a, unsigned long long int b) {
  return b ? GCD(b, a % b) : a;
}
int LCM(int a, int b) { return a / GCD(a, b) * b; }
void swop(double &a, double &b) {
  double c = a;
  a = b;
  b = c;
}
void swop(int &a, int &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
long long int u(long long int a) {
  if (a >= 0) return a;
  return a * (-1);
}
int main() {
  vector<int> c;
  int j, n, i, a, b;
  scanf("%d %d %d", &n, &a, &b);
  for (i = 0; i < n; i++) {
    scanf("%d", &j);
    c.push_back(j);
  }
  sort(c.begin(), c.end());
  printf("%d", c[n - a] - c[n - a - 1]);
  return 0;
}
