#include <bits/stdc++.h>
using namespace std;
long long n, k, q, a[200020], ans;
string s;
int main() {
  ios::sync_with_stdio(false);
  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;
}
