#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = (int)(0); i < (int)(v.size()); i++) {
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}
int main(int argc, char *argv[]) {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  for (int i = (int)(0); i < (int)(N); i++) cin >> A[i];
  sort((A).begin(), (A).end());
  cout << A[Q - 1] - A[0] << endl;
}
