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