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>
int n, k, m, a[100010], b[100010], c[100010], cnt;
long long ans;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0, j = 0; i < n; i = j) {
    for (; j < n && a[i] == a[j]; j++)
      ;
    if ((j - i) % k) {
      b[cnt] = a[i], c[cnt++] = (j - i) % k;
      if (cnt > 1 && b[cnt - 1] == b[cnt - 2]) {
        cnt--;
        (c[cnt - 1] += c[cnt]) %= k;
        if (!c[cnt - 1]) --cnt;
      }
    }
  }
  int l = 0, r = cnt - 1, el = 0;
  while (l <= r && b[l] == b[r] && (c[l] + c[r]) % k == 0)
    el += c[l++] + c[r--];
  if (l < r) {
    if (b[l] == b[r]) el += c[l] + c[r] - (c[l] + c[r]) % k;
    for (int i = 0; i < cnt; i++) ans += c[i];
    ans = ans * m - el * (m - 1ll);
  } else if (l == r) {
    int len = c[l] * 1ll * m % k;
    if (len) {
      for (int i = 0; i < cnt; i++)
        if (i != l) ans += c[i];
      ans += len;
    }
  } else if (m % 2) {
    for (int i = 0; i < cnt; i++) ans += c[i];
  }
  printf("%lld\n", ans);
}
