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 F(i,j,n) for(register int i=j;i<=n;i++)
#define H(i,j,n) for(i=j;i<=n;i++)
#define D(i,j,n) for(register int i=j;i>=n;i--)
#define ll long long
#define N 200010
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;int f;
	char gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++;
		}
		return*iS++;
	}
	template<class I>void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
};
using io::gi;
using io::gc;
int n,k,m,e,a[N],b[N*2],c[N*2],h,l,r,s,t,v;ll ans;
vector<int> x,y,z,w,p,q;
void add(int t){
	if(t)p=z,q=w;else p=x,q=y;
	int m=p.size()-1;
	F(i,1,h){
		if(p[m]==b[i])q[m]+=c[i];
		else {m++;p.push_back(b[i]);q.push_back(c[i]);}
		q[m]%=k;if(!q[m]){m--;p.pop_back();q.pop_back();}
	}
//	puts("A");F(i,1,m)printf("%d %d\n",p[i],q[i]);puts("");
	if(t)z=p,w=q;else x=p,y=q;
}
int pow(){
	while(m){
		h=x.size()-1;s=0;
		F(i,1,h)b[i]=x[i],c[i]=y[i],s+=y[i];
//		printf("%d\n",h);F(i,1,h)printf("%d %d\n",b[i],c[i]);puts("");
		if(m&1)add(1);add(0);
		h=x.size()-1;t=0;
		F(i,1,h)t+=y[i];
//		printf("%d %d %d\n",m,s,t);puts("");
		h=z.size()-1;
		if(h>=v*3){
			p=z;q=w;z.clear();w.clear();
			z.push_back(-1);w.push_back(-1);
			D(i,v*2-1,0)z.push_back(p[h-i]),w.push_back(q[h-i]);
			F(i,1,h-v*2)ans+=q[i];
		}
		m>>=1;
		h=x.size()-1;
		if(h>=v*3){
			p=x;q=y;x.clear();y.clear();
			x.push_back(-1);y.push_back(-1);
			F(i,1,v)x.push_back(p[i]),y.push_back(q[i]);
			D(i,v-1,0)x.push_back(p[h-i]),y.push_back(q[h-i]);
			s=0;F(i,v+1,h-v)s+=q[i];
			ans+=(ll)s*m;
		}
//		h=z.size()-1;printf("%d\n",h);F(i,1,h)printf("%d %d\n",z[i],w[i]);puts("");
	}
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	#endif
	gi(n);gi(k);gi(m);v=n;
	F(i,1,n)gi(a[i]);
	F(i,2,n)s|=(a[i]!=a[i-1]);e=(ll)n*m%k;
	if(!s){printf("%d\n",e);return 0;}
	if(k>=n){printf("%lld\n",(ll)n*m);return 0;}
	F(i,1,n){if(a[i]!=a[i-1])b[++l]=a[i];c[l]++;}
	F(i,1,l)c[i]%=k;
	n=0;F(i,1,l)if(c[i]){if(b[n]==b[i])c[n]+=c[i];else{n++;b[n]=b[i];c[n]=c[i];}c[n]%=k;if(!c[n])n--;}
	if(n==1){printf("%d\n",e);exit(0);}
	if(n==0){puts("0");exit(0);}
	x.push_back(-1);y.push_back(-1);
	z.push_back(-1);w.push_back(-1);
	F(i,1,n)x.push_back(b[i]),y.push_back(c[i]);
	pow();h=z.size()-1;F(i,1,h)ans+=w[i];
//	printf("%d\n",h);F(i,1,h)printf("%d %d\n",z[i],w[i]);puts("");
	printf("%lld\n",ans);
	return 0;
}
