#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, q, 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];
}
