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 java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong(), k = in.nextLong(), m = in.nextLong();
            long total = n * m;
            ArrayList<Element> v = new ArrayList<>();
            Element last = new Element(-1);
            for (int i = 0; i < n; ++i) {
                int cur = in.nextInt();
                if (cur != last.value) {
                    last = new Element(cur);
                    v.add(last);
                }
                ++last.freq;
            }
            long excluded = 0L;
            ArrayList<Element> sections = new ArrayList<>();
            for (int i = 0; i < v.size(); ++i) {
                long newVal = v.get(i).freq % k;
                excluded += v.get(i).freq - newVal;
                v.get(i).freq = newVal;
                if (v.get(i).freq > 0L) {
                    sections.add(v.get(i));
                }
            }
            int l = 0, r = sections.size() - 1;
            boolean palindromic = true;
            while (l < r) {
                if (sections.get(l).value != sections.get(r).value) {
                    palindromic = false;
                    break;
                }
                long leftPart = sections.get(l).freq;
                long rightPart = sections.get(r).freq;
                long bothParts = leftPart + rightPart;
                excluded += (m - 1L) * bothParts;
                if (bothParts % k != 0L) {
                    palindromic = false;
                    break;
                }
                ++l;
                --r;
            }
            if (palindromic && sections.size() % 2 == 1) {
                long centralPart = m * sections.get(sections.size() / 2).freq;
                excluded += centralPart - centralPart % k;
                for (int i = 0; i < sections.size() / 2; ++i) {
                    excluded += sections.get(i).freq + sections.get(sections.size() - i - 1).freq;
                }
            }
            out.println(total - excluded);
        }

        class Element {
            int value;
            long freq = 0L;

            public Element(int value) {
                this.value = value;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 65536 / 2);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

