#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int maxn = (int)2e3 + 5;
const int mod = (int)1e9 + 7;
using namespace std;
int a[maxn];
int main() {
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int ans = a[q - 1] - a[0];
  printf("%d\n", ans);
  return 0;
}
