#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, x, num;
  cin >> n >> a >> b;
  int chors[2000];
  for (int i = 0; i < n; i++) {
    cin >> chors[i];
  }
  sort(chors, chors + n);
  x = chors[b] - chors[b - 1];
  cout << x << endl;
}
