#include <bits/stdc++.h>
const int MAX = 1e5 + 9;
using namespace std;
vector<int> vi;
int main() {
  int i, n, a, b;
  int c[2010];
  cin >> n >> a >> b;
  for (i = 0; i < n; i++) cin >> c[i];
  sort(c, c + n);
  cout << c[b] - c[b - 1] << endl;
}
