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)
def main():

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



    ans = float("inf")

    for Y in set(A):

        C = []

        tmp = []

        for a in A:

            if a >= Y:

                tmp.append(a)

            else:

                if len(tmp) >= K:

                    C += sorted(tmp)[:len(tmp) - K + 1]

                tmp = []

        if len(tmp) >= K:

            C += sorted(tmp)[:len(tmp) - K + 1]



        if len(C) >= Q:

            C.sort()

            X = C[Q - 1]

            ans = min(ans, X - Y)



    print(ans)



main()
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)

def main():
    N, K, Q, *A = list(map(int, open(0).read().split()))
    ans = float("inf")
    for Y in set(A):
        C = []
        tmp = []
        for a in A:
            if a >= Y:
                tmp.append(a)
            else:
                if len(tmp) >= K:
                    C += sorted(tmp)[: len(tmp) - K + 1]
                tmp = []
        if len(tmp) >= K:
            C += sorted(tmp)[: len(tmp) - K + 1]
        if len(C) >= Q:
            C.sort()
            X = C[Q - 1]
            ans = min(ans, X - Y)
    print(ans)


main()

-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) +def main(): +    N, K, Q, *A = list(map(int, open(0).read().split())) +    ans = float("inf") +    for Y in set(A): +        C = [] +        tmp = [] +        for a in A: +            if a >= Y: +                tmp.append(a) +            else: +                if len(tmp) >= K: +                    C += sorted(tmp)[: len(tmp) - K + 1] +                tmp = [] +        if len(tmp) >= K: +            C += sorted(tmp)[: len(tmp) - K + 1] +        if len(C) >= Q: +            C.sort() +            X = C[Q - 1] +            ans = min(ans, X - Y) +    print(ans) + + +main()