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>
long long stk[5300010], num[5300010];
int o[200010];
long long minu[300010];
int main() {
  int n, k, m;
  int top = 0;
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &o[i]);
  long long ans = (long long)n * m;
  long long cntp = 0;
  top = 0;
  for (int i = 0; i < n; i++) {
    if (top > 0 && stk[top - 1] == o[i]) {
      num[top - 1]++;
      if (num[top - 1] == k) {
        cntp += num[top - 1];
        top--;
      }
      continue;
    }
    stk[top] = o[i];
    num[top] = 1;
    top++;
  }
  if (top == 0) {
    ans = 0;
    cntp = 0;
  } else if (top == 1) {
    ans -= ((long long)m * num[0] / k) * k;
    ans -= cntp * m;
    cntp = 0;
    if (ans < 0) printf("!\n");
  } else {
    m--;
    int per = 1;
    minu[per] = cntp;
    long long cntd = 0;
    int tp = 100;
    while (m > 0 && tp > 0) {
      m--;
      tp--;
      per++;
      bool flag = true;
      int sav = top;
      cntd = 0;
      for (int i = 0; i < n; i++) {
        if (top > 0 && stk[top - 1] == o[i]) {
          num[top - 1]++;
          if (num[top - 1] == k) {
            cntd += num[top - 1];
            top--;
            if (top < sav) flag = false;
          }
          continue;
        }
        stk[top] = o[i];
        num[top] = 1;
        top++;
      }
      cntp += cntd;
      minu[per] = minu[per - 1] + cntd;
      if (top == 0) {
        ans -= m / per * minu[per];
        ans -= minu[m % per];
        cntd = 0;
        if (ans - cntp < 0) printf("!\n");
        break;
      }
      if (top == 1) {
        ans -= m / per * minu[per];
        ans -= minu[m % per];
        ans -= m / per * num[0] / k * k;
        cntd = 0;
        break;
      }
      if (top > 5000000) break;
      if (flag) break;
    }
    ans -= cntd * m;
  }
  ans -= cntp;
  printf("%lld\n", ans);
  return 0;
}
