#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> A(N);
  for (long long i = 0; i < (N); ++i) cin >> A.at(i);
  sort(A.begin(), A.end());
  cout << A.at(Q - 1) - A.at(0) << endl;
}
