#include <bits/stdc++.h>
using namespace std;
int a[10000], b[10000];
void mergesort(int *a, int *b, int n) {
  int i0, i1, iRight, iEnd, width, i, j;
  for (width = 1; width < n; width <<= 1)
    for (i = 0; i < n; i += (width << 1)) {
      i0 = i;
      i1 = iRight = min(i + width, n);
      iEnd = min(i + (width << 1), n);
      for (j = i; j < iEnd; j++)
        if (i0 < iRight && (a[i0] <= a[i1] || i1 == iEnd))
          b[j] = a[i0++];
        else
          b[j] = a[i1++];
      for (j = i; j < iEnd; j++) a[j] = b[j];
    }
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int i;
  for (i = 0; i < n; i++) cin >> a[i];
  mergesort(a, b, n);
  int count = 0;
  i = 0;
  while (count < y) {
    i++;
    count++;
  }
  if (a[i] == a[i - 1])
    cout << "0";
  else
    cout << a[i] - a[i - 1] << endl;
  return 0;
}
