#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
const int MAX{200010};
int as[MAX];
int main() {
  ios::sync_with_stdio(false);
  int N, K, Q;
  cin >> N >> K >> Q;
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int k = 1; k <= N; ++k) {
    cin >> as[k];
    pq.push(as[k]);
  }
  int m = pq.top(), M = m;
  while (Q--) {
    M = pq.top();
    pq.pop();
  }
  cout << M - m << endl;
  return 0;
}
