#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e10;
signed main() {
  long long n, k, q;
  cin >> n >> k >> q;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  sort((a).begin(), (a).end());
  cout << a[q - 1] - a[0] << endl;
  return 0;
}
