#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], xr[200005];
map<int, int> mp, st;
int main() {
  int i, j, k, n, m, z = 0, c = 0, t, x, y, l, r, mid;
  cin >> n >> m >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  c = a[k - 1] - a[0];
  cout << c << endl;
}
