#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, K, Q;
  cin >> N >> K >> Q;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  auto B = A;
  sort(B.begin(), B.end());
  cout << B[Q - 1] - B[0] << endl;
}
