#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long N, K, Q;
vector<long long> A, Aorder;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K >> Q;
  for (long long i = (long long)0; i < (long long)N; i++) {
    long long inp;
    cin >> inp;
    A.push_back(inp);
    Aorder.push_back(inp);
  }
  sort(Aorder.begin(), Aorder.end());
  cout << Aorder[Q - 1] - Aorder[0] << endl;
  return 0;
  long long till = 0;
  long long l = 0;
  long long r = A.size() - 1;
  while ((l + 1) < r) {
    long long m = (l + r) / 2;
  }
  return 0;
}
