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 <cctype>
#include <cstdio>
#include <algorithm>
#define rep(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)

int get()
{
	char c;
	while (!isdigit(c=getchar()));
	int k=c-'0';
	for (; isdigit(c=getchar()); k=k*10+c-'0');
	return k;
}

using namespace std;
typedef long long ll;
const int N=1e5+10;
struct data
{
    int k,s;
} a[N];
int n,m,k,h,t;
ll ans;

int main()
{
    n=get(),k=get(),m=get();
    if (k==1)
        return puts("0"),0;
    rep(i,1,n)
    {
        int x=get();
        if (x==a[t].k)
            ++a[t].s<k? 0:--t;
        else
            a[++t]=(data){x,1};
    }
    if (t==1)
        return printf("%I64d\n",(ll)n*m%k),0;
    n=0;
    rep(i,1,t)
        n+=a[i].s;
    for (h=1; h<t && a[h].k==a[t].k && (a[h].s+a[t].s)%k==0; ans+=a[h].s+a[t].s,++h,--t);
    if (h<t)
    {
        if (a[h].k==a[t].k)
            ans+=(a[h].s+a[t].s)/k*k;
        ans*=max(0,m-1);
    }
    if (h==t)
        m%=k/__gcd(k,a[h].s),ans=ans*(m-1)+(ll)a[h].s*m/k*k;
    ans=(ll)n*m-ans;
    printf("%I64d\n",ans);
    return 0;
}
