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

//package com.company;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main
{
    static class group{
        int idx;
        int number;
        group(int a){idx = a;number = 1;}
    }
    static int[] arr;
    static group[] g;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int k = sc.nextInt(); int m = sc.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        List<group> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int c = arr[i];
            if (g.size() == 0 || g.get(g.size() - 1).idx != c){
                g.add( new group(c));
            } else {
                g.get(g.size() - 1).number += 1;
            }
        }
        for (int i = 0; i < g.size(); i++) {
            g.get(i).number %= k;
        }
        for (Iterator<group> iterator = g.iterator(); iterator.hasNext();) {
            group g1 = iterator.next();
            if (g1.number == 0) {
                iterator.remove();
            }
        }
        long pending = 0;
        int idx = 0;
        while (idx < g.size() / 2){
            if (g.get(idx).idx != g.get(g.size() - 1 - idx).idx) break;
            int rem = g.get(idx).number + g.get(g.size() - 1 - idx).number;
            int rest = rem%k;
            pending += rem - rest;
            g.get(g.size() - 1 - idx).number = 0;
            g.get(idx).number = rest;
            if (rest == 0){
                idx++;
            } else {
                break;
            }
        }
        for (Iterator<group> iterator = g.iterator(); iterator.hasNext();) {
            group g1 = iterator.next();
            if (g1.number == 0) {
                iterator.remove();
            }
        }
        int isze =0;
        for (int i = 0; i < g.size(); i++) {
            isze += g.get(i).number;
        }
        if (g.size() == 1){
            int num = g.get(g.size() - 1).number;
            long res = (long) num * (long)m;
            res %= k;
            System.out.println(res);
            return;
        }
        if (isze == 0){
            System.out.println(m % 2 == 1 ? pending : 0);
        } else {
            System.out.println((long)pending + (long)m * (long)isze);
        }
    }
}