#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
void mysort(vector<long long> &a) { sort(a.begin(), a.end()); }
int main() {
  ll n, k, q;
  cin >> n >> k >> q;
  vll a(n);
  for (auto &i : a) cin >> i;
  mysort(a);
  cout << a.at(q - 1) - a.at(0) << endl;
}
