#include <bits/stdc++.h>
using namespace std;
int A[2010];
int main(void) {
  int N, K, Q;
  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;
}
