#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, q;
  cin >> n >> k >> q;
  vector<long long> nms;
  for (int i = 0; i < n; i++) {
    long long t;
    cin >> t;
    nms.push_back(t);
  }
  sort(nms.begin(), nms.end());
  cout << nms[q - 1] - nms[0] << endl;
  return 0;
}
