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