#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
inline void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
};
template <typename T, typename S>
inline ostream& operator<<(ostream& os, const pair<T, S> p) {
  cout << "[" << p.first << ";" << p.second << "]";
  return os;
}
template <typename T, typename S>
inline ostream& operator<<(ostream& os, const map<T, S> p) {
  for (auto el : p) cout << "[" << el.first << ";" << el.second << "]";
  return os;
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
template <typename T>
inline vector<T> fetch_vec(int sz) {
  vector<T> ret(sz);
  for (auto& elem : ret) cin >> elem;
  return ret;
}
int N, K, Q;
vector<ll> A;
void input() {
  fast_io();
  cin >> N >> K >> Q;
  A = fetch_vec<ll>(N);
}
int solve() {
  sort(A.begin(), A.end());
  cout << (A[Q - 1] - A[0]) << endl;
  return 0;
}
int main() {
  input();
  solve();
  return 0;
}
