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