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