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