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