#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
long long fast_exp(long long base, long long exp) {
  long long tot = 1;
  for (; exp > 0; exp >>= 1) {
    if ((exp & 1) == 1) tot = tot * base % MOD;
    base = base * base % MOD;
  }
  return tot;
}
int arr[2001];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  cout << arr[q - 1] - arr[0] << "\n";
  return 0;
}
