#include <bits/stdc++.h>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;
using namespace std;
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << (a[Q - 1] - a[0]) << endl;
  return 0;
}
