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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int k = in.nextInt();
        long m = in.nextLong();
        long[] arr = new long[n];

        long prev = in.nextLong();
        long cnt = 1;
        int end = 0;
        arr[end] = prev;
        int start = 0;
        for (long i = 1; i < n; i++) {
            end++;
            long v = in.nextLong();
            arr[end] = v;
            if (v == prev) {
                cnt++;
                if (cnt == k) {
                    end -= k;
                    if (end < 0) {
                        prev = -1;
                        end = -1;
                        continue;
                    }
                    prev = arr[end];
                    cnt = 1;
                    int e = end - 1;
                    while (e >= 0 && arr[e] == prev) {
                        cnt++;
                        e--;
                    }
                }
            } else {
                prev = v;
                cnt = 1;
            }
        }

        int foundTeams = 0;
        while (arr[start] == arr[end] && start != end) {
            cnt = 0;
            long v = arr[start];
            int s = start;
            int e = end;
            while (arr[s] == v) {
                cnt++;
                s++;
            }
            while (arr[e] == v) {
                cnt++;
                e--;
            }
            if (cnt == k) {
                start = s;
                end = e;
                foundTeams++;
            } else if (cnt > k) {
                foundTeams++;
                break;
            } else {
                break;
            }
        }

        long result = (end - start + 1) * m + foundTeams * k;
        if (start == end) {
            result = m % k;
        }
        System.out.println(result);

    }

    public static int gcd(int a, int b) {
        int t;
        while (b != 0) {
            t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    public static void pa(List<Object> objs) {
        String str = "";
        for (Object obj : objs) {
            str += obj.toString() + " ";
        }
        p(str);
    }

    public static void pa(int[] objs) {
        String str = "";
        for (int i = 0; i < objs.length; i++) {
            str += objs[i] + " ";
        }
        p(str);
    }

    static void p(Object str) {
        System.out.println(str);
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
