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