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