#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 10;
int n;
int a[maxi];
int d[maxi];
int b[maxi];
int m;
int main() {
  int n, k, q;
  cin >> n >> k >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  cout << a[q] - a[1] << endl;
}
