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