import heapq



def main():

    _, k, q = list(map(int, input().split()))

    a = tuple(map(int, input().split()))



    gs = [a]

    m = float('inf')

    for y in sorted(set(a)):

        gs = groups(gs, y, k)

        x = find_x(gs, y, k, q)

        if x is None:

            break

        m = min(m, x - y)

    

    print(m)



def find_x(gs, y, k, q):

    xs = []



    for g in gs:

        xs.extend(heapq.nsmallest(len(g) - k + 1, g))

    

    xss = heapq.nsmallest(q, xs)

    if len(xss) < q:

        return None

    

    return xss[-1]



def groups(gs, m, k):

    new_gs = []

    for g in gs:

        new_gs.extend(groups_1(g, m, k))

    return new_gs



def groups_1(a, m, k):

    g = []



    pos = 0

    while pos < len(a):

        i = pos

        while i < len(a) and a[i] < m:

            i += 1

        

        j = i

        while j < len(a) and a[j] >= m:

            j += 1

        

        if j - i >= k:

            g.append(a[i:j])

        

        pos = j

    

    return g



main()
import heapq



def main():

    _, k, q = list(map(int, input().split()))

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

    idx = make_index(a)

    groups = [(0, len(a))]



    m = float('inf')

    for y in sorted(set(a)):

        xs = []

        for start, stop in groups:

            xs.extend(nsmallest(stop - start - k + 1, a, start, stop))



        if len(xs) < q:

            break



        xxs = heapq.nsmallest(q, xs)

        x = xxs[-1]

        m = min(m, x - y)



        groups = split_groups(idx[y], groups, k)



    print(m)



MEMO = dict()

def nsmallest(n, a, start, stop):

    global MEMO

    key = (n, id(a), start, stop)

    if key in MEMO:

        return MEMO[key]



    val = heapq.nsmallest(n, a[start:stop])

    MEMO[key] = val

    return val



def split_groups(pivots, groups, k):

    gs = []



    i = 0

    for start, stop in groups:

        while i < len(pivots) and pivots[i] < start:

            i += 1

        while i < len(pivots) and pivots[i] <= stop:

            if pivots[i] - start >= k:

                gs.append((start, pivots[i]))

            start = pivots[i] + 1

            i += 1



        if stop - start >= k:

            gs.append((start, stop))



    return gs





def make_index(a):

    idx = dict()



    for i, x in enumerate(a):

        if x in idx:

            idx[x].append(i)

        else:

            idx[x] = [i]



    return idx



main()

import heapq


def main():
    _, k, q = list(map(int, input().split()))
    a = tuple(map(int, input().split()))
    gs = [a]
    m = float("inf")
    for y in sorted(set(a)):
        gs = groups(gs, y, k)
        x = find_x(gs, y, k, q)
        if x is None:
            break
        m = min(m, x - y)
    print(m)


def find_x(gs, y, k, q):
    xs = []
    for g in gs:
        xs.extend(heapq.nsmallest(len(g) - k + 1, g))
    xss = heapq.nsmallest(q, xs)
    if len(xss) < q:
        return None
    return xss[-1]


def groups(gs, m, k):
    new_gs = []
    for g in gs:
        new_gs.extend(groups_1(g, m, k))
    return new_gs


def groups_1(a, m, k):
    g = []
    pos = 0
    while pos < len(a):
        i = pos
        while i < len(a) and a[i] < m:
            i += 1
        j = i
        while j < len(a) and a[j] >= m:
            j += 1
        if j - i >= k:
            g.append(a[i:j])
        pos = j
    return g


main()

import heapq


def main():
    _, k, q = list(map(int, input().split()))
    a = list(map(int, input().split()))
    idx = make_index(a)
    groups = [(0, len(a))]
    m = float("inf")
    for y in sorted(set(a)):
        xs = []
        for start, stop in groups:
            xs.extend(nsmallest(stop - start - k + 1, a, start, stop))
        if len(xs) < q:
            break
        xxs = heapq.nsmallest(q, xs)
        x = xxs[-1]
        m = min(m, x - y)
        groups = split_groups(idx[y], groups, k)
    print(m)


MEMO = dict()


def nsmallest(n, a, start, stop):
    global MEMO
    key = (n, id(a), start, stop)
    if key in MEMO:
        return MEMO[key]
    val = heapq.nsmallest(n, a[start:stop])
    MEMO[key] = val
    return val


def split_groups(pivots, groups, k):
    gs = []
    i = 0
    for start, stop in groups:
        while i < len(pivots) and pivots[i] < start:
            i += 1
        while i < len(pivots) and pivots[i] <= stop:
            if pivots[i] - start >= k:
                gs.append((start, pivots[i]))
            start = pivots[i] + 1
            i += 1
        if stop - start >= k:
            gs.append((start, stop))
    return gs


def make_index(a):
    idx = dict()
    for i, x in enumerate(a):
        if x in idx:
            idx[x].append(i)
        else:
            idx[x] = [i]
    return idx


main()

-    a = tuple(map(int, input().split())) -    gs = [a] +    a = list(map(int, input().split())) +    idx = make_index(a) +    groups = [(0, len(a))] -        gs = groups(gs, y, k) -        x = find_x(gs, y, k, q) -        if x is None: +        xs = [] +        for start, stop in groups: +            xs.extend(nsmallest(stop - start - k + 1, a, start, stop)) +        if len(xs) < q: +        xxs = heapq.nsmallest(q, xs) +        x = xxs[-1] +        groups = split_groups(idx[y], groups, k) -def find_x(gs, y, k, q): -    xs = [] -    for g in gs: -        xs.extend(heapq.nsmallest(len(g) - k + 1, g)) -    xss = heapq.nsmallest(q, xs) -    if len(xss) < q: -        return None -    return xss[-1] +MEMO = dict() -def groups(gs, m, k): -    new_gs = [] -    for g in gs: -        new_gs.extend(groups_1(g, m, k)) -    return new_gs +def nsmallest(n, a, start, stop): +    global MEMO +    key = (n, id(a), start, stop) +    if key in MEMO: +        return MEMO[key] +    val = heapq.nsmallest(n, a[start:stop]) +    MEMO[key] = val +    return val -def groups_1(a, m, k): -    g = [] -    pos = 0 -    while pos < len(a): -        i = pos -        while i < len(a) and a[i] < m: +def split_groups(pivots, groups, k): +    gs = [] +    i = 0 +    for start, stop in groups: +        while i < len(pivots) and pivots[i] < start: -        j = i -        while j < len(a) and a[j] >= m: -            j += 1 -        if j - i >= k: -            g.append(a[i:j]) -        pos = j -    return g +        while i < len(pivots) and pivots[i] <= stop: +            if pivots[i] - start >= k: +                gs.append((start, pivots[i])) +            start = pivots[i] + 1 +            i += 1 +        if stop - start >= k: +            gs.append((start, stop)) +    return gs + + +def make_index(a): +    idx = dict() +    for i, x in enumerate(a): +        if x in idx: +            idx[x].append(i) +        else: +            idx[x] = [i] +    return idx