#include <bits/stdc++.h>
using namespace std;
const int MAXN = 700 + 5;
set<pair<int, int> > s[(1 << 18)];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  cout << arr[q - 1] - arr[0] << endl;
  return 0;
}
