#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n);
  vector<int> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort((b).begin(), (b).end());
  cout << b[q - 1] - b[0] << endl;
  return 0;
}
