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.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);
		}
		ArrayList<couple> p = new ArrayList<couple>();
		int f = 0,l=0;
		for(int i=1;i<n;i++)
		{
			if(arr[i]!=arr[f] && i-f<k)
			{
				p.add(new couple(f,i-1));
				f=i;
			}
			if(i==n-1 && i-f<k)
			{
				p.add(new couple(f,i));
				f=i;
			}
		}
		ArrayList<Long> fina = new ArrayList<Long>();
		for(couple it :p)
		{
			int i = it.i;
			int j = it.j;
			for(int x = i;x<=j;x++)
				fina.add(arr[x]);
		}
		f = 0; l = fina.size() - 1;
		int curf = -1, curl = fina.size();
		Stack<Long> st = new Stack<Long>();

		while (f<=l) {
			if (st.size()>0 && fina.get(l) != st.peek() && fina.get(f) != st.peek() && st.size() < k) {
				st.clear();
				break;
			}
			if (st.size()==0 ||  (fina.get(l) == st.peek() && st.size() < k) )
				st.push(fina.get(l--));
			if (st.size() == k) {
				curf = f - 1;
				curl = l + 1;
				st.clear();
			}
			if (st.size()==0 ||  (fina.get(f) == st.peek() && st.size() < k) )
				st.push(fina.get(f++));
			if (st.size() == k) {
				curf = f - 1;
				curl = l + 1;
				st.clear();
			}
		}
		if(f>l)
		{
			System.out.println(0);
			System.exit(0);
		}
		long remo = curf+1 + fina.size() - curl;
		long ans = fina.size()*m - remo*(m-1); 
		System.out.println(ans);
	}
}
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;
	}
}