10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

import queue

def readTuple():
    return input().split()
def readInts():
    return tuple(map(int, readTuple()))

def solve():
    n, k,  m = readInts()
    nums = []
    cnt = 0
    for i in readInts():
        if nums and i == nums[-1][0]:
            nums[-1][1] +=1
            if nums[-1][1] == k:
                nums.pop()
            continue
        nums.append([i,1])
    i, j = 0, len(nums)-1
    comm = 0
    while i<j:
        if nums[i][0] == nums[j][0]:
           if nums[i][1]+nums[j][1] == k:
                comm +=1
        else:
            break
        i+=1
        j-=1

    mid = len(nums)-2*comm
    prefix_sum = sum(map(lambda x: x[1], nums[:comm]))
    middle_sum = sum(map(lambda x: x[1], nums[comm:comm+mid]))
    suffix_sum = sum(map(lambda x: x[1], nums[comm+mid:]))
    all_sum = (prefix_sum+suffix_sum+middle_sum)*m

    # print(nums)
    # print("prefix: ", comm, "SUM: ", prefix_sum)
    # print("mid: ", mid, "SUM: ", middle_sum)
    # print("suffix: ", comm, "SUM: ", suffix_sum)
    # print("ALL: ", all_sum)
    #subtract perfect matches
    all_sum -= (prefix_sum+suffix_sum)*(m-1)
    if mid == 0:
        all_sum = 0
    elif mid == 1:
        if m%k == 0:
            all_sum = 0
        else:
            all_sum -= (m//k)*middle_sum*k
    else:
        if nums[comm][0] == nums[-comm-1][0] \
           and nums[comm][1]+nums[-comm-1][1] > k:
            all_sum -= k*(m-1)
    print(all_sum)

if __name__ == '__main__':
    solve()

