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.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;

public class rounndd {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int m = sc.nextInt();
		Queue<Integer> q = new LinkedList<>();
		Stack<Integer> st = new Stack<>();
		boolean allEq = true;
		int last = -1;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			allEq &= (x == last || i == 0);
			q.add(x);
			st.add(x);
			last = x;
		}
		if (k > n && allEq) {
			System.out.println(1l * n * m % k);
			return;
		}
		long ans = 0;
		while (!q.isEmpty() && !st.isEmpty()) {
			last = q.peek();
			int count = 0;
			while (!q.isEmpty() && q.peek() == last) {
				count++;
				q.poll();
			}
			ans += 1l * (count / k) * m;
			count %= k;
			if (count == 0) {
				last = st.peek();
			}
			int lastMod = count;
			while (!st.isEmpty() && st.peek() == last) {
				st.pop();
				count++;
			}
			if (count % k >= lastMod)
				ans += 1l * (count / k) * m;
			else {
				ans += 1l * (count / k) * m - 1;
			}
			count %= k;
			if (n - q.size() - lastMod == st.size()) {
				ans += ((1l * count * m / 2 + (m % 2 == 1 ? count - lastMod : 0))) / k;
				if (((1l * count * m / 2 + (m % 2 == 1 ? count - lastMod : 0))) % k == 0)
					ans += (q.size() + st.size()) / k;
			}
			if (count != 0)
				break;
		}
		while (st.size() > n - q.size()) {
			int top = st.peek();
			int count = 0;
			while (!st.isEmpty() && st.peek() == top) {
				count++;
				st.pop();
			}
			ans += 1l * (count / k) * m;
		}
		System.out.println(Math.max(1l * n * m - ans * k, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public boolean nextEmpty() throws IOException {
			String s = nextLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}
	}
}
