#include <bits/stdc++.h>
char ch;
bool fs;
void re(int& x) {
  while (ch = getchar(), ch < 33)
    ;
  if (ch == '-')
    fs = 1, x = 0;
  else
    fs = 0, x = ch - 48;
  while (ch = getchar(), ch > 33) x = x * 10 + ch - 48;
  if (fs) x = -x;
}
using namespace std;
int n, k, q, a[2001];
int main() {
  re(n);
  re(k);
  re(q);
  for (int i = 1; i <= n; ++i) re(a[i]);
  sort(a + 1, a + n + 1);
  printf("%d\n", a[q] - a[1]);
}
