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