from itertools import*

N,K,Q,*A=list(map(int,open(0).read().split()))

l=len

s=sorted

a=1e9

for Y in set(A):

	C=s(sum((v[:l(v)-K+1]for v in(s(v)for k,v in groupby(A,lambda a:a>=Y)if k)if l(v)>=K),[]))

	if l(C)>=Q:a=min(a,C[Q-1]-Y)

print(a)
n,k,q,*a=list(map(int,open(0).read().split()))

s=sorted

m=1e9

for b in a:

    i=[i for i,t in enumerate(a)if t<b]

    l=s(sum([s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])],[]))

    if len(l)>=q:m=min(m,l[q-1]-b)

print(m)
from itertools import *

N, K, Q, *A = list(map(int, open(0).read().split()))
l = len
s = sorted
a = 1e9
for Y in set(A):
    C = s(
        sum(
            (
                v[: l(v) - K + 1]
                for v in (s(v) for k, v in groupby(A, lambda a: a >= Y) if k)
                if l(v) >= K
            ),
            [],
        )
    )
    if l(C) >= Q:
        a = min(a, C[Q - 1] - Y)
print(a)

n, k, q, *a = list(map(int, open(0).read().split()))
s = sorted
m = 1e9
for b in a:
    i = [i for i, t in enumerate(a) if t < b]
    l = s(sum([s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])], []))
    if len(l) >= q:
        m = min(m, l[q - 1] - b)
print(m)

-from itertools import * - -N, K, Q, *A = list(map(int, open(0).read().split())) -l = len +n, k, q, *a = list(map(int, open(0).read().split())) -a = 1e9 -for Y in set(A): -    C = s( -        sum( -            ( -                v[: l(v) - K + 1] -                for v in (s(v) for k, v in groupby(A, lambda a: a >= Y) if k) -                if l(v) >= K -            ), -            [], -        ) -    ) -    if l(C) >= Q: -        a = min(a, C[Q - 1] - Y) -print(a) +m = 1e9 +for b in a: +    i = [i for i, t in enumerate(a) if t < b] +    l = s(sum([s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])], [])) +    if len(l) >= q: +        m = min(m, l[q - 1] - b) +print(m)