#include <bits/stdc++.h>
using namespace std;
long long n, a, b, arr[2005];
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  cin >> n >> a >> b;
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  cout << arr[b] - arr[b - 1] << endl;
  return 0;
}
