#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, N = 2e5 + 5;
const long long INF = 1e18, MOD = 1e9 + 7;
;
long long power(long long a, long long b, long long m = MOD) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) r = r * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return r;
}
long long gcd(long long a, long long b) {
  if (b > a) swap(a, b);
  if (!b) return a;
  return gcd(b, a % b);
}
long long a[N], n, k, q, ma = -inf, mi = inf;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cout << setprecision(10) << fixed;
  cin >> n >> k >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= q; i++) {
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }
  cout << ma - mi;
  return 0;
}
