#include <bits/stdc++.h>
using namespace std;
int V[3000];
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  sort(V, V + N);
  int x = V[B] - V[B - 1];
  cout << x << endl;
}
