#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long int mod = 1e9 + 7, INF = 1e18;
long long int dx[8] = {0, -1, 1, 0, 1, -1, 1, -1},
              dy[8] = {1, 0, 0, -1, -1, -1, 1, 1};
long long int N, K, Q, A;
priority_queue<long long int, vector<long long int>, greater<long long int> >
    que;
int main() {
  cin >> N >> K >> Q;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    cin >> A;
    que.push(A);
  }
  long long int minv = que.top();
  for (long long int i = (0), i_end_ = (Q - 1); i < i_end_; i++) {
    que.pop();
  }
  cout << que.top() - minv << '\n';
}
