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