#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>

#include <cassert>
#include <cmath>
#include <ctime>

using namespace std;

mt19937 mt (736);

template<class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

class dsu
{
    vector<int> par, siz;
    vector<minheap<int>> val;
    priority_queue<int> avail;

    int k, q;

public:
    dsu (const vector<int> &arr, int k, int q) : par (arr.size (), -1),
        siz (arr.size (), 1), val (arr.size ()), k (k), q (q)
    {
        for (int i = 0; i < arr.size (); i++)
            val[i].push (arr[i]);
    }

    int get_class (int t)
    {
        return par[t] == -1 ? t : par[t] = get_class (par[t]);
    }

    void mark (int a)
    {
        a = get_class (a);

        while (val[a].size () >= k)
        {
            avail.push (val[a].top ());
            val[a].pop ();

            if (avail.size () > q)
                avail.pop ();
        }
    }

    bool unite (int a, int b)
    {
        a = get_class (a);
        b = get_class (b);

        if (a == b)
            return false;

        uniform_int_distribution<int> uid (0, siz[a] + siz[b] - 1);

        if (val[b].size () > val[a].size ())
            val[a].swap (val[b]);

        while (!val[b].empty ())
        {
            val[a].push (val[b].top ());
            val[b].pop ();
        }

        while (val[a].size () >= k)
        {
            avail.push (val[a].top ());
            val[a].pop ();

            if (avail.size () > q)
                avail.pop ();
        }

        if (uid (mt) < siz[a])
        {
            par[b] = a;
            siz[a] += siz[b];
        }
        else
        {
            par[a] = b;
            siz[b] += siz[a];
            val[a].swap (val[b]);
        }

        return true;
    }

    int get () const
    {
        return avail.size () == q ? avail.top () : numeric_limits<int>::max ();
    }
};

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    int n, k, q;

    cin >> n >> k >> q;

    vector<int> arr (n);

    for (auto &it : arr)
        cin >> it;

    dsu slv (arr, k, q);

    vector<pair<int, int>> ord (n);

    for (int i = 0; i < ord.size (); i++)
        ord[i] = make_pair(arr[i], i);

    sort (ord.begin (), ord.end (), greater<pair<int, int>> ());

    int ans = numeric_limits<int>::max ();

    for (auto it : ord)
    {
        int wh = it.second;
        int val = it.first;

        slv.mark (wh);        if (wh != 0 && arr[wh - 1] >= val)
            slv.unite (wh - 1, wh);
        if (wh != arr.size () - 1 && arr[wh + 1] >= val)
            slv.unite (wh, wh + 1);

        ans = min (ans, slv.get () - val);
    }

    cout << ans << endl;
}

int main ()
{
    ios_base::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);

#ifdef LOCAL
    solve ();

    cout << "clock: " << clock () / (double)CLOCKS_PER_SEC << endl;
#else
    solve ();
#endif

    return 0;
}


Measured memory_bytes: 512