#include <bits/stdc++.h>
using ll = int_fast64_t;
int main() {
  ll n, k, q;
  scanf("%ld %ld %ld", &n, &k, &q);
  std::vector<ll> a(n);
  for (ll i = 0; i < n; i++) scanf("%ld", &a[i]);
  std::sort(a.begin(), a.end());
  printf("%ld\n", a[q - 1] - a[0]);
  return 0;
}
