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>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 1e6 + 7;
int s[N], h[N], a[N];
signed main() {
  ios::sync_with_stdio(false);
  int n, m, k, top = 0;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[++top]);
    if (top == 1 || s[top] != s[top - 1])
      h[top] = 1;
    else
      h[top] = h[top - 1] + 1;
    if (h[top] == k) top -= k;
  }
  int L = 1, R = top, l, r, cnt;
  long long ans = 0;
  while (L < R && s[L] == s[R]) {
    cnt = 0, l = L, r = R;
    while (l < R && s[l] == s[L] && cnt < k) cnt++, l++;
    while (r > l && s[r] == s[R] && cnt < k) cnt++, r--;
    if (cnt == k)
      ans += (long long)k, L = l, R = r;
    else
      break;
  }
  long long _ans = (long long)(R - L + 1) * (long long)m;
  int flag = 1;
  for (int i = L; i < R; i++)
    if (s[i] != s[i + 1]) {
      flag = 0;
      break;
    }
  if (!flag)
    ans += _ans;
  else {
    _ans %= (long long)k;
    if (_ans == 0ll)
      ans = 0;
    else
      ans += _ans;
  }
  printf("%lld\n", ans);
  return 0;
}
