#include <bits/stdc++.h>
using namespace std;
int N, K, Q;
int A[2001];
int main(int argc, char** argv) {
  std::ios::sync_with_stdio(false);
  cin >> N >> K >> Q;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  cout << A[Q - 1] - A[0] << endl;
  return 0;
}
