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