#include <bits/stdc++.h>
using namespace std;
template <typename tn>
void read(tn& a) {
  tn x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  a = f == 1 ? x : -x;
}
const int MAXN = 210000;
const int Ln = 22;
const int INF = 2e9;
int n, k, q;
int a[MAXN], b[MAXN];
int ans;
void solve() {
  for (int i = 1; i <= n; ++i) b[i] = a[i];
  sort(b + 1, b + 1 + n);
  ans = b[q] - b[1];
}
int main() {
  read(n);
  read(k);
  read(q);
  for (int i = 1; i <= n; ++i) read(a[i]);
  solve();
  cout << ans << "\n";
  return 0;
}
