#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char const *argv[]) {
  int n, k, q;
  std::cin >> n >> k >> q;
  std::vector<int> a(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  sort(a.begin(), a.end());
  std::cout << a[q - 1] - a[0] << '\n';
  return 0;
}
