#include <bits/stdc++.h>
using namespace std;
int v[2000];
int a, b, n, res;
int main() {
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  sort(v, v + n);
  int res = v[b] - v[b - 1];
  cout << res << endl;
}
