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