#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const long long INF = 9999999;
int n, x, y;
int a[N];
int main() {
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  cout << a[y] - a[1];
  return 0;
}
