#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k, q;
  cin >> n >> k >> q;
  vector<long long> a(n);
  for (auto& i : a) cin >> i;
  sort(a.begin(), a.end());
  cout << a[q - 1] - a[0] << endl;
}
