#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int a[2020];
void solve() {
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  int c = 0;
  cout << a[x - 1] - a[x];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T = 1;
  while (T--) solve();
}
