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

#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 0;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++) 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double PI = acos(-1.0);
const double eps = 1e-9;
using namespace std;
#define N 200100
#define int ll

main () {

	ll n,m,k;

	cin >> n >> k >> m;

	ii v[N];

	int sz = 0;
	ll res = 0;
	for(int i=0;i<n;i++) {
		cin >> v[sz].fi;
		if(sz > 0 and v[sz-1].fi == v[sz].fi) {
			v[sz-1].se++;
			v[sz-1].se == k;
			sz--;
			res += k;
		} else {
			v[sz].se = 1;
			sz++;
		}
	}

	for(int i=0;i<sz;i++) {
		prin(v[i].fi);
		v[i+sz] = v[i];
	}

	ll add = 0;
	int i;
	for(i=0;i<sz;i++) {
		if(v[sz+i].fi == v[sz-i-1].fi and (v[sz+i].se + v[sz-i-1].se) % k == 0) {
			add += (v[sz+i].se + v[sz-i-1].se);	
		} else break;
	}
	
	prin(i);
	prin(v[i].fi);
	prin(v[i].se);
	prin(add);
	prin(res);

	if(sz % 2 == 1 and i == sz/2) {
		res = 0;
		if(((v[i].se * m) % k) != 0) {
			res += (v[i].se*m) % k;
			for(int j=0;j<sz;j++) {
				if(j == i) continue;
				res += (ll)v[i].se;
			}
		}
		printf("%lld\n", res);
	} else if(i >= sz/2) {
		cout << 0 << endl;
	} else {
		res = res * m + (m-1LL) * add;
		printf("%lld\n", n*m - res);
	}

	return 0;

}



