#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
template <class T, class U>
void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template <class T>
void init_n(vector<T>& v, size_t n) {
  init_n(v, n, T());
}
template <class T>
void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i = 0; i < n; ++i) cin >> v[i];
}
template <class T, class U>
void read_n(vector<pair<T, U>>& v, size_t n) {
  v = vector<pair<T, U>>(n);
  for (lli i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
}
template <class T>
T gabs(const T& x) {
  return max(x, -x);
}
lli n, k, q;
vector<lli> a;
int main() {
  cin >> n >> k >> q;
  read_n(a, n);
  sort(begin(a), end(a));
  cout << a[q - 1] - a[0] << endl;
  return 0;
}
