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.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.StringTokenizer;


// 12321
// 123434343434343434343421

public class b {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int k = in.nextInt(), m = in.nextInt();
		int[] as = new int[n];
		for(int i=0;i<n;i++) {
			as[i] = in.nextInt();
		}
		long ans = 0;
		ArrayDeque<Count> stk = new ArrayDeque<>();
		for(int i=0;i<n;i++) {
			Count c = stk.peek();
			if(c != null && c.v == as[i]) {
				c.cnt++;
				if(c.cnt == k) {
					stk.pop();
				}
			} else {
				stk.push(new Count(as[i], 1));
			}
		}
		Count[] cs = new Count[stk.size()];
		while(!stk.isEmpty()) {
			cs[stk.size()-1] = stk.pop();
		}
		for(int i=0;i<cs.length;i++) {
			Count first = cs[i], last = cs[cs.length-1-i];
			if(first.v != last.v || m == 1) {
				for(int j=i;j<=cs.length-1-i;j++) {
					ans += m*(long)cs[j].cnt;
				}
				break;
			}
			if(first == last) {
				ans += (first.cnt * (long)m)%k;
				if(((first.cnt * (long)m) % k) == 0) {
					for(int j=i-1;j>=0;j--) {
						first = cs[j];
						last = cs[cs.length-1-j];
						long sum = first.cnt + last.cnt;
						ans -= sum;
						ans += sum % k;
						if(sum % k != 0) break;
					}
				}
				break;
			}
			long sum = first.cnt + last.cnt;
			if(sum % k != 0) {
				ans += (sum%k)*(m-1);
				ans += sum;
				for(int j=i+1;j<=cs.length-1-i-1;j++) {
					ans += m*(long)cs[j].cnt;
				}
				break;
			} else {
				ans += sum;
			}
		}
		out.println(ans);
//		System.out.println(Arrays.toString(cs));
		
		out.close();
	}
	static class Count {
		int v, cnt;
		public Count(int v, int cnt) {
			this.v = v;
			this.cnt = cnt;
		}
		@Override
		public String toString() {
			return "[" + v + " x" + cnt + "]";
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}
		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 double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}
		public long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}
		public String[] nextStringArray(int n) throws IOException {
			String[] arr = new String[n];
			for (int i = 0; i < n; i++)
				arr[i] = next();
			return arr;
		}
	}
}