#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int max, num, sub_str;
  int temp;
  int res_max, res_min;
  vector<int> v;
  res_min = 1000000000;
  res_max = 1;
  cin >> num >> sub_str >> max;
  for (int i = 0; i < num; i++) {
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < max; i++) {
    if (v[i] > res_max) res_max = v[i];
    if (v[i] < res_min) res_min = v[i];
  }
  cout << res_max - res_min << '\n';
  return 0;
}
