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