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);
		}

		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.push(new Coup(arr[i], count + 1));
			} else {
				s.push(new Coup(arr[i], 1));
			}
			if (s.peek().count == k) {
				long te = k;
				while (te-- > 0)
					s.pop();
			}
		}
		ArrayList<Long> fina = new ArrayList<Long>();

		while (!s.isEmpty()) {
			fina.add(s.peek().ele);
			s.pop();
		}
		Collections.reverse(fina);

		int 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(f==l)
			{
			    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();
			    }continue;
			}
			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) {
			long te = st.size();
			te = te*m;
			if(te%k==0)
			System.out.println(0);
			else
			{
				long ans = te%k;
				long remo = fina.size() - st.size();
				ans += remo;
				System.out.println(ans);
			}
			System.exit(0);
		}
		long remo = curf + 1 + fina.size() - curl;
		long ans = fina.size() * m - remo * (m - 1);
		System.out.println(ans);
	}
}

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;
	}
}