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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 3e5;
const int SQRTN = 300;
const int LOGN = 16;
const int INT_INFINITY = 1001001001;
const slong LONG_INFINITY = 2001001001001001001ll;
const double EPS = 1e-6;

const slong VERYHIGH = 2001001001001ll;
const int LIMIT = 1e6;

slong n, k, m;
int arr[MAXN+5];

slong calcAns(vector<int> reducedArr, slong m)
{
	if ((m <= 1) || reducedArr.empty())
	{
		return 0;
	}
	
	stack<int> st;
	queue<int> qu;

	for (auto s: reducedArr)
	{
		st.push(s);
		qu.push(s);
	}

	slong rem = 0;

	bool hasbreak = false;
	
	int removelast = 0;
	int removefront = 0;

	slong ans = 0;

	while (!st.empty() && !qu.empty())
	{
		int last = st.top();
		int front = qu.front();

		if (last != front)
		{
			//no more removals
			hasbreak = true;
			break;
		}

		int countLast = 0;
		int countFront = 0;

		while (!st.empty() && (st.top() == last))
		{
			removelast++;
			countLast++;
			st.pop();
		}

		while (!qu.empty() && (qu.front() == front))
		{
			removefront++;
			countFront++;
			qu.pop();
		}

		slong tot = countLast + countFront;

		slong x = tot/k;
		rem += 1ll*x*k;

		if (tot % k)
		{
			//no more possible
			
			if ((removefront+removefront) >= reducedArr.size())
			{
				slong curr = (tot % k)*(m/2);
				
				if (m % 2 == 1)
				{
					for (int i = 0; i < reducedArr.size(); i++)
					{
						if (reducedArr[i] == front)
						{
							curr++;
						}
						else
						{
							break;
						}
					}
				}
						
				slong x = curr/k;
				ans += 1ll*x*k;

			}
			
			hasbreak = true;
			break;
		}
	}

	if ((removefront+removefront) >= reducedArr.size())
	{
		ans += (m/2)*rem;
	}
	else if (hasbreak)
	{
		//mid element
		ans += (m-1)*rem;
	}
	else if (st.empty())
	{
		//qu non empty
		vector<int> newarr;

		while (!qu.empty())
		{
			auto s = qu.front();
			qu.pop();
			newarr.pb(s);
		}

		ans += calcAns(newarr, (m+1)/2);
	}
	else if (qu.empty())
	{
		//st non empty
		vector<int> newarr;

		while (!st.empty())
		{
			auto s = st.top();
			st.pop();
			newarr.pb(s);
		}

		ans += calcAns(newarr, (m+1)/2);
	}

	return ans;
}

int main()
{
	#ifdef VSP4
		//freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	
	int i, j, d;
	
	clong3(n, k, m);

	set<int> data;

	for (i = 1; i <= n; i++)
	{
		cint(arr[i]);
		data.insert(arr[i]);
	}

	if (data.size() == 1)
	{
		//all elements equal
		//n*m array
		slong size = 1ll*n*m;
		slong x = size/k;

		cout << 1ll*n*m - 1ll*x*k;
		return 0;
	}
	else
	{
		vector<int> reducedArr;

		slong ans = 0;

		for (i = 1; i <= n;)
		{
			int countSame = 0;
			int ele = arr[i];

			for (j = i; j <= n; j++)
			{
				if (ele == arr[j])
				{
					countSame++;
				}
				else
				{
					break;
				}
			}

			i += countSame;

			while (countSame >= k)
			{
				ans += 1ll*m*k;
				countSame -= k;
			}

			//push elements
			
			while (countSame--)
			{
				reducedArr.pb(ele);
			}
		}

		if (!reducedArr.empty())
		{
			ans += calcAns(reducedArr, m);
		}
		
		cout << 1ll*n*m - ans;

	}

	return 0;
}
