#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  int ret = 0, p = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * p;
}
int n, q, k;
int a[300000 + 3];
int main() {
  n = read();
  k = read();
  q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  printf("%d\n", a[q] - a[1]);
  return 0;
}
