#include <bits/stdc++.h>
using namespace std;
int a[2001];
int main() {
  ios::sync_with_stdio(false);
  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];
}
