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

#n=int(raw_input())
n,k,m=[int(ii) for ii in raw_input().split(" ")]
a=[int(ii) for ii in raw_input().split(" ")]


s=n
dnb={}
for ii in a:
    if ii not in dnb:
        dnb[ii]=1
    else:
        dnb[ii]+=1

if dnb.values()[0]==s:
    print ((m%k)*(n%k))%k
else:
    isok=False
    vires=0
    nbcut=0
    nbcut2=0
    #check the chain sizes...
# start the chain at -j
    j=0
    while a[j-1]==a[0]:
        j-=1
    chains={} #each chain has :  id,start,end,city, idnext, idbefore
    x=a[j]
    idc=0
    start=j
    for kk in range(j+1,n+j):
        if a[kk]!=x:
            chains[idc]={"start":start,"end":kk,"city":x,"before":idc-1,"after":idc+1,} if idc>0 else {"start":start,"city":x,"end":kk,"after":idc+1}
            chains[idc]["l"]=kk-start            
            start=kk
            x=a[kk]
            idc+=1
    chains[idc]={"start":start,"end":n+j,"city":x,"before":idc-1,"after":0,"l":n+j-start}
    chains[0]["before"]=idc
    if j<0:
        chains[0]["lb"]=-j
        chains[0]["la"]=chains[0]["l"]+j
    for kk in sorted(chains.keys()):
        v=chains[kk]
        if v["before"]==v["after"]: #ct la derniere chaine c beau non, donc il restera forcement nm%k dailleurs c couvre le cas 1 ptet
            isok=True
            l=v["l"]
            break
        else:
            if v["l"]>=k:
                vires+=k*(v["l"]/k)
                if v["start"]<0:
                    nbcut+=v["l"]%k
                    nbcut2+=(v["lb"]%k)+(v["la"]%k)
                v["l"]%=k
            #if we have 0 v["l"] left, we give the last to the next iff they have same city
            if v["l"]==0:
                vp=chains[v["before"]]
                vn=chains[v["after"]]
                if vn["city"]==vp["city"]:
                    vn["before"]=vp["before"]
                    vn["start"]=vp["start"]
                    vn["la"]=vn["l"]
                    vn["lb"]=vp["l"]
                    vn["l"]+=vp["l"]
    if isok:
        reste=((l%k)*(m%k))%k
        if reste==0:
            print ((m%k)*(n%k))%k
        else:
            print nbcut2+reste
    else:
        print (n-vires)*m + (nbcut2-nbcut)