#include <bits/stdc++.h>
using namespace std;
int inf = (1e9) + 7;
int main() {
  int n;
  int a, b;
  scanf("%d %d %d", &n, &a, &b);
  vector<int> v;
  int aux;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &aux);
    v.push_back(aux);
  }
  sort(v.begin(), v.end());
  printf("%d\n", v[b] - v[b - 1]);
}
