#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long c = gcd(a, b);
  return ((a / c) * (b / c) * c);
}
const long long INF = 1e9 + 7;
const long long N = 300002;
class Seg_Tree {
 public:
  vector<int> dat;
  int n;
  void initsize(int n0) {
    int k = 1;
    while (1) {
      if (n0 <= k) {
        n = k;
        dat.resize(2 * n - 1);
        for (int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX;
        break;
      }
      k *= 2;
    }
  }
  void update(int i, int x) {
    i += n - 1;
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  int query0(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b)
      return dat[k];
    else {
      int vl = query0(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query0(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr);
    }
  }
  int query(int a, int b) { return query0(a, b, 0, 0, n); }
};
long long n, k, q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> q;
  vector<long long> v;
  for (long long i = (0); i < (n); ++i) {
    long long k;
    cin >> k;
    v.push_back(k);
  }
  (sort(v.begin(), v.end()));
  long long mi, ma;
  mi = v[0];
  ma = v[q - 1];
  cout << (ma - mi) << endl;
  return 0;
}
