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.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		int k;
		long m;

		public class LinkedListRepeatedObject {
			int number, count;
			int countRepeatObject;

			LinkedListRepeatedObject next = null, prev = null;

			public LinkedListRepeatedObject(int value, int c, int r) {
				number = value;
				count = c;
				countRepeatObject = r;
			}

			public void invalidate() {
				while (prev != null && prev.number == number) {
					count += prev.count;
					prev.count = 0;
					countRepeatObject += prev.countRepeatObject;
					prev.countRepeatObject = 0;
					prev = prev.prev;
					if (prev != null) {
						prev.next = this;
					}
				}
				while (next != null && next.number == number) {
					count += next.count;
					next.count = 0;
					countRepeatObject += next.countRepeatObject;
					next.countRepeatObject = 0;
					next = next.next;
					if (next != null) {
						next.prev = this;
					}
				}

				if (count >= k) {
					int temp = count % k;
					temp = count - temp;
					countRepeatObject -= temp;
					count %= k;
					if (countRepeatObject < 0) {
						countRepeatObject = 0;
					}
					if (count == 0) {
						if (prev != null) {
							prev.next = next;
						}
						if (next != null) {
							next.prev = prev;
						}
						prev.invalidate();
						prev = null;
						next = null;
					}
				}
				if (countRepeatObject != 0 && (prev == this) && (next == this)) {
					count += countRepeatObject * (m - 3);
					countRepeatObject = 0;
					invalidate();
				}
			}
		}

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			// int n = in.nextInt();
			// int k = in.nextInt();
			// int[][] s = new int[n][k];
			// for (int i = 0; i < n; i++) {
			// for (int j = 0; j < k; j++) {
			// s[i][j] = in.nextInt();
			// }
			// }
			int n = in.nextInt();
			k = in.nextInt();
			m = in.nextInt();
			LinkedListRepeatedObject[] a;
			if (m >= 3)
				a = new LinkedListRepeatedObject[3 * n];
			else if (m == 2)
				a = new LinkedListRepeatedObject[2 * n];
			else
				a = new LinkedListRepeatedObject[n];
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				a[i] = new LinkedListRepeatedObject(x, 1, 0);
				if (m == 2) {
					a[n + i] = new LinkedListRepeatedObject(x, 1, 0);
				} else if (m >= 3) {
					a[n + i] = new LinkedListRepeatedObject(x, 1, 1);
					a[n * 2 + i] = new LinkedListRepeatedObject(x, 1, 0);
				}
			}
			for (int i = 0; i < a.length; i++) {
				if (i != 0) {
					a[i].prev = a[i - 1];
				}
				if (i != a.length - 1) {
					a[i].next = a[i + 1];
				}
			}
			if (m <= 3) {
				for (LinkedListRepeatedObject aa : a) {
					aa.invalidate();
				}
			} else {
				a[n * 2 - 1].next = null;
				a[n * 2].prev = null;
				for (LinkedListRepeatedObject aa : a) {
					aa.invalidate();
				}
				for (int i = n * 2 - 1; i >= 0; i--) {
					if (a[i].count != 0) {
						for (int j = 2 * n; j < 3 * n; j++) {
							a[j].prev = a[i];
							a[i].next = a[j];
						}
					}
				}
			}
			long count = 0;
			for (LinkedListRepeatedObject aa : a) {
				count += aa.count;
				count += ((long) aa.countRepeatObject) * (m - 3);
			}
			out.println(count);
		}
	}

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

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			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());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

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

	}
}