#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int n, q, k;
int arr[MAXN];
void solve() {
  int i = 0;
  sort(arr, arr + n);
  cout << arr[q - 1] - arr[0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k >> q;
  int i = 0;
  for (i = 0; i < n; i++) cin >> arr[i];
  solve();
  return 0;
}
