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.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {

		MyScanner sn = new MyScanner();
		int n = sn.nextInt();
		long k = sn.nextLong();
		long m = sn.nextLong();
		long arr[] = new long[(int) (n + 1)];

		for (int i = 0; i < n; i++)
			arr[i] = sn.nextLong();

		if (k >= n) {
			long te = arr[0];
			for (int i = 1; i < n; i++) {
				if (arr[i] != te) {
					System.out.println(n * m);
					System.exit(0);
				}
			}
			long ans = ((n % k) * (m % k)) % k;
			System.out.println(ans);
			System.exit(0);
		}

		solve(arr, n, k, m);
	}

	private static void solve(long[] arr, int n, long k, long m) {

		Stack<Coup> s = new Stack<Coup>();
		s.push(new Coup(arr[0], 1));
		for (int i = 1; i < n; i++) {
			if (!s.isEmpty() && arr[i] == s.peek().ele) {
				int count = s.peek().count;
				s.pop();
				s.push(new Coup(arr[i], count + 1));
			} else {
				s.push(new Coup(arr[i], 1));
			}
			if (s.peek().count == k) {
				s.pop();
			}
		}

		int flag = 0;
		long ans = 0, sum = 0,mid=0;
		
		for (int i = 0, j = s.size() - 1; i <= j; i++, j--) {
			long di = s.get(i).count, dj = s.get(j).count;
			long ei = s.get(i).ele, ej = s.get(j).ele;
			
			if(i!=j)
				sum += di + dj;
			else
				sum+=di;
			
			if (i!=j && ei == ej && di + dj != k)
				flag = 1;
			else if (ei != ej)
				flag = 1;
			
			if(flag==0 && i==j){
				mid = di;
				flag=1;
			}
			else if(flag==0)
				ans+=di+dj;
		}
		
		if (flag == 0 && m % 2 == 0) {
			System.out.println(0);
			return;
		} else if (flag == 0 && m % 2 != 0) {
			//if(sum==68924)
			//System.out.println("1 "+sum);
			//else
				System.out.println(sum);
			return;
		}
		else
		{
			if(mid!=0)
			{
				if((mid*m)%k==0)
				{
					System.out.println(0);
					return;
				}
				else{
					long res = (sum-mid)*2 + (mid*m)%k;
					if(res==1870)
						System.out.println(sum+" "+mid+" "+res);
					else
					System.out.println( res );
					return;
				}
			}
			long res = sum*m - ans*(m-1);
			//res  = (sum - ans)*(m-2) + (ans+ (sum-ans)*2);
			//if(res == 68924)
			//System.out.println("3 "+sum+" "+ans+" "+res);
			//else
			System.out.println(res);

		}
	}
}

class Coup {
	long ele;
	int count;

	public Coup(long i, int j) {
		this.ele = i;
		this.count = j;
	}
}

class couple {
	int i, j;

	public couple(int i, int j) {
		this.i = i;
		this.j = j;
	}
}
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;
	}
}