#include <bits/stdc++.h>
using namespace std;
int n, ki, qi, ai[500010];
inline int readin() {
  int x = 0, s = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') s = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * s;
}
int main() {
  n = readin();
  ki = readin();
  qi = readin();
  for (int i = 1; i <= n; ++i) ai[i] = readin();
  sort(ai + 1, ai + n + 1);
  cout << ai[qi] - ai[1] << endl;
  return 0;
}
