#include <bits/stdc++.h>
using namespace std;
template <class t>
long long int gcd(t g, t h) {
  return (h == 0 ? g : gcd(h, g % h));
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
} comp_functor;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int i, j, k, n, ans, x, y, a[3000006], temp = 0, h[3000006] = {0},
                                                   t[21][300005], p, q, f;
  string s;
  cin >> n >> k >> q;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  ans = a[q - 1] - a[0];
  cout << ans;
  return 0;
}
