#include <bits/stdc++.h>

using namespace std;
#define int long long

const int MAXN = 2007;
const int INF = 2e9 + 7;

int a[MAXN];
int v[MAXN];

bool comp(int i, int j) {
    return a[i] < a[j];
}

int tree[MAXN * 4];
int sum[MAXN * 4];

void build(int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = a[tl];
        sum[v] = 1;
        return;
    }

    int tm = (tl + tr) / 2;
    build(v * 2 + 1, tl, tm);
    build(v * 2 + 2, tm + 1, tr);
    tree[v] = min(tree[v * 2 + 1], tree[v * 2 + 2]);
    sum[v] = sum[v * 2 + 1] + sum[v * 2 + 2];
}

void upd(int v, int tl, int tr, int p) {
    if (tl == tr) {
        tree[v] = INF;
        sum[v] = 0;
        return;
    }

    int tm = (tl + tr) / 2;
    if (p <= tm) upd(v * 2 + 1, tl, tm, p);
    else upd(v * 2 + 2, tm + 1, tr, p);

    tree[v] = min(tree[v * 2 + 1], tree[v * 2 + 2]);
    sum[v] = sum[v * 2 + 1] + sum[v * 2 + 2];
}

int getmin(int v, int tl, int tr, int l, int r) {
    if (tr < l || r < tl) return INF;
    if (l <= tl && tr <= r) return tree[v];
    int tm = (tl + tr) / 2;
    return min(getmin(v * 2 + 1, tl, tm, l, r), getmin(v * 2 + 2, tm + 1, tr, l, r));
}

int getsum(int v, int tl, int tr, int l, int r) {
    if (tr < l || r < tl) return 0;
    if (l <= tl && tr <= r) return sum[v];
    int tm = (tl + tr) / 2;
    return getsum(v * 2 + 1, tl, tm, l, r) + getsum(v * 2 + 2, tm + 1, tr, l, r);
}

int getl_(int v, int tl, int tr, int l, int r, int x) {
    if (tr < l || r < tl) return -1;
    if (x <= tree[v]) return -1;
    if (tl == tr) return tl;
    int tm = (tl + tr) / 2;
    int lres = getl_(v * 2 + 1, tl, tm, l, r, x);
    if (lres != -1) return lres;
    else return getl_(v * 2 + 2, tm + 1, tr, l, r, x);
}

int getr_(int v, int tl, int tr, int l, int r, int x) {
    if (tr < l || r < tl) return -1;
    if (x <= tree[v]) return -1;
    if (tl == tr) return tl;
    int tm = (tl + tr) / 2;
    int rres = getr_(v * 2 + 2, tm + 1, tr, l, r, x);
    if (rres != -1) return rres;
    else return getr_(v * 2 + 1, tl, tm, l, r, x);
}

int getl(int i, int x, int n) {
    if (x <= getmin(0, 0, n - 1, 0, i)) return -1;
    else return getr_(0, 0, n - 1, 0, i - 1, x);
}

int getr(int i, int x, int n) {
    if (x <= getmin(0, 0, n - 1, i, n - 1)) return n;
    else return getl_(0, 0, n - 1, i, n - 1, x); 
}

bool ch(int i, int x, int n, int k) {
    int l = getl(i, x, n);
    int r = getr(i, x, n);
    int len = getsum(0, 0, n - 1, l + 1, r - 1);
    return k <= len;
}

bool check(int l, int r, int n, int k, int q) {
    vector <int> can;
    for (int i = 0; i < n; ++i) {
        if (l <= a[i] && a[i] <= r) can.push_back(i);
    }

    sort(can.begin(), can.end(), comp);

    build(0, 0, n - 1);

    int del = 0;
    for (int i : can) {
        if (ch(i, a[i], n, k)) {
            ++del;
            upd(0, 0, n - 1, i);
        }
    }

    return q <= del;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];    

    set <int> ms;
    for (int i = 0; i < n; ++i) ms.insert(a[i]);

    int p = 0;
    for (int elem : ms) v[p++] = elem;

    int ans = INF;
    int u = -1;
    for (int l = 0; l < p; ++l) {
        u = max(u, l);
        while (u < p && !check(v[l], v[u], n, k, q)) ++u;
        if (u == p) break;
        ans = min(ans, v[u] - v[l]);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512