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