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