#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T my_pow(T n, T p) {
  if (p == 0) return 1;
  T x = my_pow(n, p / 2);
  x = (x * x);
  if (p & 1) x = (x * n);
  return x;
}
template <class T>
T big_mod(T n, T p, T m) {
  if (p == 0) return (T)1;
  T x = big_mod(n, p / 2, m);
  x = (x * x) % m;
  if (p & 1) x = (x * n) % m;
  return x;
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
T multiplication(T n, T p, T m) {
  if (p == 0) return (T)0;
  T x = multiplication(n, p / 2, m);
  x = (x + x) % m;
  if (p & 1) x = (x + n) % m;
  return x;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <class T>
T extract(string s, T ret) {
  stringstream ss(s);
  ss >> ret;
  return ret;
}
template <class T>
string tos(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
long long toi(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double toDouble(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
const int mod = 1e9 + 7;
long long a, b, n, m, res = 0, c = 0, t = 0, ans = 0, cc = 0, f = 0, ff = 0,
                      cnt = 0;
long long mn = (1e15), mx = -(1e15);
string s, ss, ch[100010];
long long dp[2005][2005];
long long rec(long long a, long long b) {
  if (a > n) return 0LL;
  if (b > m) return 0LL;
  if (a <= b) return 0LL;
  if (a == n && b == m) return 1LL;
  long long &res = dp[a][b];
  if (res != -1) return res % mod;
  res = 0;
  res += rec(a + 1, b);
  if (res >= mod) res %= mod;
  res += rec(a, b + 1);
  if (res >= mod) res %= mod;
  return res;
}
long long recc(long long a, long long b) {
  if (a > n) return 0LL;
  if (b > m) return 0LL;
  if (a > b) return 0LL;
  if (a == m && b == m) return 1LL;
  long long &res = dp[a][b];
  if (res != -1) return res;
  res = 0;
  res += recc(a, b + 1);
  res %= mod;
  res += recc(a + 1, b);
  res %= mod;
  return res;
}
long long ar[100100];
int main() {
  cin >> n >> a >> b;
  for (__typeof(n) i = 0; i < (n); i++) cin >> ar[i];
  sort(ar, ar + n);
  long long mn = 1e9;
  int i = 0;
  long long aa = ar[b - 1];
  long long bb = ar[b];
  cout << bb - aa;
  return 0;
}
