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

//package codeForce8;

import java.util.*;


public class line {

	static ArrayDeque<Long> left = new ArrayDeque<Long>();
	static ArrayDeque<Long> right = new ArrayDeque<Long>();
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long k = in.nextLong();
		long m = in.nextLong();
		long result = n * m;
		
		long prev = 0;
		long length = 0;
		ArrayDeque<Long> queue = new ArrayDeque<Long>();
		for(long i = 0; i < n; i++)
		{
			long current = in.nextLong();
			queue.addLast(current);
			
			if(current != prev)
			{
				prev = current;
				length = 1;
			}
			else
			{
				length++;
			}
			
			if(length == k)
			{
				//prev = 0;
				length = 0;
				result -= k * m;
				for(long j = 0; j < k; j++)
				{
					queue.removeLast();
				}
			}
			
		}
		//long leftOver = 0;
		//long last = 0;
		while(true)
		{
			if(queue.size() == 0)//handled
			{		
				System.out.println(0);
				System.exit(0);
			}
			if(queue.size() <= k)
			{
				boolean same = true;
				Iterator<Long> it = queue.iterator();
				long first = it.next();
				while(it.hasNext())
				{
					if(it.next() != first)
					{
						same = false;
						break;
					}
				}
				
				if(!same)
				{
					
					handle(queue,k,result);
				}
				else
				{
					result = (queue.size() * m) % k;
					if(result == 0)
					{
						System.out.println("0");
						System.exit(0);
					}
					else
					{
						queue = new ArrayDeque<Long>();
						for(int i = 0; i < result; i++)
						{
							queue.add(first);
						}
						handle(queue,k,result);
					}
				}
			}
			else
			{
				if(queue.peekFirst() == queue.peekLast())//handled.
				{
					long target = queue.removeLast();
					queue.removeFirst();
					long length1 = 2;
					while(queue.peekLast() == target)
					{
						length1++;
						queue.removeLast();
					}
					if(length1 == k)
					{
						result -= k * m;
						//last = target;
						//leftOver++;
						left.addLast(target);
						for(int i = 0; i < k - 1; i++)
						{
							right.addFirst(target);
						}
						continue;
					}
					else
					{
						long diff = k - length1;
						long removed = 0;
						boolean success = true;
						for(long i = 0; i < diff; i++)
						{
							if(queue.peekFirst() != target)
							{
								//result += leftOver * k;
								removed = i;	
								success = false;
								break;
							}
							else
							{
								queue.removeFirst();
							}
						}
						if(success)
						{
							result -= k * m;
							//last = target;
							//leftOver++;
							for(int i = 0; i < diff; i++)
							{
								left.addLast(target);
							}
							for(int i = 0; i < length1 - 1; i++)
							{
								right.addFirst(target);
							}
							continue;
						}
						else
						{
							queue.addFirst(target);
							for(int i = 0; i < removed; i++)
							{
								queue.addFirst(target);
							}
							for(int i = 0; i < length1 - 1; i++)
							{
								queue.addLast(target);
								handle(queue, k, result);
							}
						}
					}
				}
				else
				{
					handle(queue, k, result);
				}
			}
		}

	}
	
	private static void handle(ArrayDeque<Long> leftOver, long k, long result)
	{
		ArrayDeque<Long> finalOne = new ArrayDeque<Long>();
		if(k == 1)
		{		
			finalOne.addAll(left);
			finalOne.addAll(leftOver);
			finalOne.addAll(right);
			
		}
		else
		{
			finalOne.addAll(left);
			finalOne.addAll(leftOver);
			finalOne.addAll(leftOver);
			finalOne.addAll(right);
		}
		
		result += left.size();
		result += right.size();
		
		long prev = 0;
		long length = 0;
		Iterator<Long> it = finalOne.iterator();
		while(it.hasNext())
		{
			long current = it.next();
			if(current != prev)
			{
				length = 1;
				prev = current;
			}
			else
			{
				length++;
			}
			
			if(length == k)
			{
				//prev = 0;
				length = 0;
				result -= k;
				
			}
		}
		
		System.out.println(result);
		System.exit(0);
	}

}
