#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, k, q;
  while (cin >> n >> k >> q) {
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    cout << a[q - 1] - a[0] << endl;
  }
  return 0;
}
