#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  printf("%d\n", a[--q] - a[0]);
  return 0;
}
