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