#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
const int INF = 1e9 + 5;
int a[MAXN + 5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, K, Q;
  cin >> N >> K >> Q;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  cout << a[Q - 1] - a[0] << "\n";
}
