import sys

input = sys.stdin.readline



import heapq as hp





def main():

    N, K, Q = list(map(int, input().split()))

    A = list(map(int, input().split()))



    NUM = sorted(list(set(A)))



    ans = 10**10

    for n in NUM:

        Qs = []

        q = []

        for i in range(N):

            if A[i] < n:

                if q:

                    Qs.append(q)

                    q = []

                continue

            if not q:

                q = [A[i]]

            else:

                hp.heappush(q, A[i])

        if q:

            Qs.append(q)

        P = []

        for q in Qs:

            l = len(q)

            if l < K: continue

            for _ in range(min(Q, l-K+1)):

                v = hp.heappop(q)

                P.append(v)

        if len(P) < Q:

            break

        P.sort()

        ans = min(ans, P[Q-1]-P[0])

    print(ans)





if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline

import heapq as hp



N, K, Q = list(map(int, input().split()))

A = list(map(int, input().split()))

Xs = sorted(list(set(A)))



ans = 10**14

for x in Xs:

    Ps = []

    tmp = []

    for a in A:

        if a >= x:

            tmp.append(a)

        else:

            if len(tmp) >= K:

                Ps.append(tmp)

            tmp = []

    if len(tmp) >= K:

        Ps.append(tmp)

    q = []

    for P in Ps:

        P.sort()

        for i, p in enumerate(P):

            q.append(p)

            if len(P)-K-i == 0: break

    if len(q) < Q:

        break

    q.sort()

    ans = min(ans, q[Q-1]-x)



print(ans)

    
import sys

input = sys.stdin.readline
import heapq as hp


def main():
    N, K, Q = list(map(int, input().split()))
    A = list(map(int, input().split()))
    NUM = sorted(list(set(A)))
    ans = 10**10
    for n in NUM:
        Qs = []
        q = []
        for i in range(N):
            if A[i] < n:
                if q:
                    Qs.append(q)
                    q = []
                continue
            if not q:
                q = [A[i]]
            else:
                hp.heappush(q, A[i])
        if q:
            Qs.append(q)
        P = []
        for q in Qs:
            l = len(q)
            if l < K:
                continue
            for _ in range(min(Q, l - K + 1)):
                v = hp.heappop(q)
                P.append(v)
        if len(P) < Q:
            break
        P.sort()
        ans = min(ans, P[Q - 1] - P[0])
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
import heapq as hp

N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
Xs = sorted(list(set(A)))
ans = 10**14
for x in Xs:
    Ps = []
    tmp = []
    for a in A:
        if a >= x:
            tmp.append(a)
        else:
            if len(tmp) >= K:
                Ps.append(tmp)
            tmp = []
    if len(tmp) >= K:
        Ps.append(tmp)
    q = []
    for P in Ps:
        P.sort()
        for i, p in enumerate(P):
            q.append(p)
            if len(P) - K - i == 0:
                break
    if len(q) < Q:
        break
    q.sort()
    ans = min(ans, q[Q - 1] - x)
print(ans)

- -def main(): -    N, K, Q = list(map(int, input().split())) -    A = list(map(int, input().split())) -    NUM = sorted(list(set(A))) -    ans = 10**10 -    for n in NUM: -        Qs = [] -        q = [] -        for i in range(N): -            if A[i] < n: -                if q: -                    Qs.append(q) -                    q = [] -                continue -            if not q: -                q = [A[i]] -            else: -                hp.heappush(q, A[i]) -        if q: -            Qs.append(q) -        P = [] -        for q in Qs: -            l = len(q) -            if l < K: -                continue -            for _ in range(min(Q, l - K + 1)): -                v = hp.heappop(q) -                P.append(v) -        if len(P) < Q: -            break +N, K, Q = list(map(int, input().split())) +A = list(map(int, input().split())) +Xs = sorted(list(set(A))) +ans = 10**14 +for x in Xs: +    Ps = [] +    tmp = [] +    for a in A: +        if a >= x: +            tmp.append(a) +        else: +            if len(tmp) >= K: +                Ps.append(tmp) +            tmp = [] +    if len(tmp) >= K: +        Ps.append(tmp) +    q = [] +    for P in Ps: -        ans = min(ans, P[Q - 1] - P[0]) -    print(ans) - - -if __name__ == "__main__": -    main() +        for i, p in enumerate(P): +            q.append(p) +            if len(P) - K - i == 0: +                break +    if len(q) < Q: +        break +    q.sort() +    ans = min(ans, q[Q - 1] - x) +print(ans)