#include <bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long> > pq;
map<int, int> mp;
map<int, int> mp2;
char vowels[] = {'a', 'o', 'e', 'u', 'i'};
int A[2 * 100000];
bitset<64> bt;
set<int> st;
int n, m;
long long x, y, z;
bool isvowels(char a) {
  for (int i = 0; i < 5; i++)
    if (a == vowels[i]) return true;
  return false;
}
int binary_search(int x) {
  int l = 0, r = 500, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid * (mid + 1) == x)
      break;
    else if (mid * (mid + 1) >= x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (mid * (mid + 1) == x)
    return mid;
  else
    return -1;
}
bool bal(string z) {
  string x = z;
  reverse(x.begin(), x.end());
  if (z == x)
    return true;
  else
    return false;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
int main() {
  fast();
  int a, b;
  cin >> n >> a >> b;
  vector<int> vc(n);
  for (int i = 0; i < n; i++) cin >> vc[i];
  sort(vc.begin(), vc.end());
  cout << vc[n - a] - vc[b - 1];
}
