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>
using namespace std;
long long an;
int n, m, k, i, h, t, cnt, mi, mx, S, V1, Vt, a[222222], b[222222], v[222222];
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &m);
  mi = 1e9;
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), mi = min(mi, a[i]), mx = max(mx, a[i]);
  for (int i = 1; i <= n; i++) {
    cnt++;
    if (a[i] != a[i + 1]) b[++t] = a[i], v[t] = cnt, cnt = 0;
  }
  for (int i = 1; i <= t; i++) S += v[i] % k;
  if (mi == mx) return printf("%d", 1ll * n * m % k), 0;
  if (b[1] != b[t]) return printf("%I64d", 1ll * S * m), 0;
  V1 = v[1];
  Vt = v[t];
  for (h = 1; b[h] == b[t] && v[h] + v[t] >= k && h < t;) {
    v[h] -= k - v[t];
    t--;
    if (!v[h]) h++;
  }
  if (h == t) {
    if (v[h] * m % k == 0)
      printf("%d", (V1 + Vt) % k);
    else {
      if (b[1] == b[h])
        printf("%I64d", (1ll * v[h] * m + V1 + Vt) % k);
      else
        printf("%I64d", 1ll * v[h] * m % k + (V1 + Vt) % k);
    }
  } else {
    S = 0;
    for (i = h; i <= t; i++) S += v[i];
    an = 1ll * S * m + V1 + Vt;
    if (b[1] == b[h]) an -= V1 + v[h] - (V1 + v[h]) % k;
    if (b[t] == b[1]) an -= Vt + v[t] - (Vt + v[t]) % k;
    printf("%I64d", an);
  }
}
