// algo.cpp: 定义应用程序的入口点。
//
#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <climits>
#include <cassert>
using namespace std;
struct UnionFind {
    vector<int> par, sz;
    int n_tree;

    explicit UnionFind(int n) : par(n), sz(n, 1), n_tree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_cluster() const {
        return n_tree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --n_tree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool is_root(int x) const {
        return par[x] == x;
    }
};
int main()
{
#ifdef LOCAL
    // 如何使用相对路径？
    ifstream in(R"(C:\Users\zjsdu\source\repos\algo\algo\in.txt)");
    cin.rdbuf(in.rdbuf());
#endif
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> b(n);
    iota(b.begin(), b.end(), 0);
    sort(b.begin(), b.end(), [&](int x, int y) {return a[x] > a[y];});
    UnionFind left(n), right(n);
    vector<int> c;
    priority_queue<int> global_que;
    vector<priority_queue<int, vector<int>, greater<>>> que(n);
    for (int i = 0; i < n; ++i) {
        que[i].push(a[i]);
    }
    auto merge_heap = [&](int i, int j) {
        assert(i < j);
        if (que[i].size() < que[j].size()) {
            swap(que[i], que[j]);
        }
        while (!que[j].empty()) {
            que[i].push(que[j].top());
            que[j].pop();
        }
    };
    auto enque = [&](int val) {
        if (global_que.size() < q) {
            global_que.push(val);
        }
        else if (global_que.top() > val) {
            global_que.pop();
            global_que.push(val);
        }
    };

    int min_val{};
    int ans = INT_MAX;
    for (int i = 0; i <= n; ++i) {
        if (i == n || i > 0 && a[b[i]] != a[b[i - 1]]) {
            for (int j : c) {
                if (j  - 1 >= 0 && a[j - 1] >= a[j] && !left.same(j - 1, j)) {
                    merge_heap(left.root(j - 1), j);
                    left.unite(j, j - 1);
                    right.unite(j - 1, j);
                }
                if (j + 1 < n && a[j + 1] >= a[j] && !left.same(j, j + 1)) {
                    merge_heap(left.root(j), left.root(j + 1));
                    left.unite(j + 1, j);
                    right.unite(j, j + 1);
                }
                int id = left.root(j);
                if (que[id].size() >= k) {
                    min_val = a[j];
                }
                while (que[id].size() >= k) {
                    enque(que[id].top());
                    que[id].pop();
                }
            }
            c.clear();
            if (global_que.size() >= q) {
                ans = min(ans, global_que.top() - min_val);
            }
        }
        //for (int i = 0; i < n; ++i) {
        //    cout << left.root(i) << ' ';
        //}
        //cout << endl;
        if (i < n) {
            c.push_back(b[i]);
        }
    }
    cout << ans << '\n';
#if defined LOCAL
    cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 512