#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
struct edge {
  long long to, cost;
};
long long a[2005];
signed main() {
  long long n, k, q;
  cin >> n >> k >> q;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ans = 0;
  cout << a[q - 1] - a[0] << endl;
}
