#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int oo = 0x3f3f3f3f;
template <typename T>
inline void rd(T &x) {
  x = 0;
  int f = 1;
  char CH = getchar();
  while (!isdigit(CH)) {
    if (CH == '-') f = 0;
    CH = getchar();
  }
  while (isdigit(CH)) {
    x = ((x + (x << 2)) << 1) + (CH - 48);
    CH = getchar();
  }
  x = (f == 1) ? x : -x;
  return;
}
const int MXN = 2e3 + 5;
int n, a[MXN], k, q;
int main() {
  rd(n), rd(k), rd(q);
  for (register int i = (1), i_end = (n); i <= i_end; ++i) rd(a[i]);
  sort(a + 1, a + 1 + n);
  cout << a[q] - a[1];
}
