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