#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t INF = 1e18;
double EPS = 0.00000001;
int main() {
  int64_t n, k, q;
  cin >> n >> k >> q;
  vector<int64_t> a(n);
  for (int64_t i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  cout << (a[q - 1] - a[0]) << endl;
  return 0;
}
