#include <bits/stdc++.h>
using namespace std;
const int N = 20005;
int A[N];
int main() {
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 0; i < n; ++i) cin >> A[i];
  sort(A, A + n);
  int ans = A[q - 1] - A[0];
  cout << ans << endl;
  return 0;
}
