#include <bits/stdc++.h>
using namespace std;
long long n, m, k, a, b, c;
vector<long long> v;
int main(void) {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  cout << v[k - 1] - v[0] << endl;
}
