#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[2010], a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + 1 + n);
  if (arr[b] == arr[b + 1])
    cout << 0 << "\n";
  else {
    cout << arr[b + 1] - arr[b] << "\n";
  }
}
