#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 17;
const int MOD = 1e9 + 7;
long long a[MAXN];
int main(int argc, char const* argv[]) {
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << a[q - 1] - a[0] << endl;
  return 0;
}
