#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e6 + 10;
const int inf = (int)1e9;
long long arr[N];
int main() {
  int n;
  scanf("%d", &n);
  int k, q;
  cin >> k >> q;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  sort(arr + 1, arr + n + 1);
  printf("%lld\n", abs(arr[q] - arr[1]));
  return 0;
}
