#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int main() {
  cin >> n;
  int k, q;
  cin >> k >> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  cout << a[q - 1] - a[0] << endl;
  return 0;
}
