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;
int n, k, m;
int l = 1, r, q[1000100], sum[1000100];
long long ans;
int top, a[1000100];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  ans = (long long)n * m;
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (l <= r && x == q[r]) {
      sum[r]++;
      if (sum[r] == k) {
        ans -= (long long)k * m;
        sum[r] = 0;
        r--;
      }
    } else {
      q[++r] = x;
      sum[r] = 1;
    }
  }
  if (l == r) {
    ans -= (long long)k * ((long long)sum[r] * m % k);
    printf("%lld\n", ans);
    return 0;
  }
  while (1) {
    if (l < r && q[l] == q[r] && sum[l] + sum[r] >= k) {
      ans -= (long long)(m - 1) * k;
      if (sum[l] + sum[r] == k) {
        top++;
        a[top] = sum[l] + sum[r];
        l++;
        r--;
      } else
        break;
    } else if (l == r) {
      long long now = (long long)m * sum[l];
      ans -= k * (now / k);
      if (now % k != 0) break;
      l++;
      r--;
    } else if (l > r) {
      while (top && a[top] >= k) {
        ans -= k;
        if (a[top] == k)
          top--;
        else
          break;
      }
      break;
    } else
      break;
  }
  printf("%lld\n", ans);
}
