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,k,m = input().strip().split()
n = int(n)
k = int(k)
m = int(m)
a = list(map(int, input().strip().split()))
x = []
kol = 1
for i in range(n):
  if i ==0:
    x.append((a[i],kol))
  else:
    if a[i] == a[i-1]:
      kol +=1
      x.append((a[i],kol))
    else:
      kol = 1
      x.append((a[i],kol))
i = n-1
s = 2 * n
l=0
if k>=n:
  for i in range(n):
    if (i>0 and a[i]!=a[i-1]):
      l =1
      break
  if l==1:
    print(n*m)
  else:
    if k <= n*m:
      print((n *m) % k)
    else:
      print(n*m)
else:
  l=0
  for i in range(n//2):
    if a[i] != a[n - i-1]:
      l = 1
  if l==0:
    print(0)
  else:
    s = 0
    i = n-1
    while i  >= n //2 - 1:
     
      if x[i] == x[n -1 - i  + x[i][1] - 1] and x[i][1] * 2 >=k:
        if i !=n -1 - i  + x[i][1] - 1:
          s += ((x[i][1] *2 //k) * k) * (m-1)
        else:
          s+= x[i][1] * m
        i = i - ((x[i][1] *2 //k) * k)//2
      else:
        i = -1
        break
    s = n*m-s
    print("f",s)