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>
struct s {
  long long v, sum;
} b[100005];
long long a[100005];
int main() {
  long long n, k, m;
  scanf("%I64d %I64d %I64d", &n, &k, &m);
  long long tot = 0;
  for (long long i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i]);
    if (tot > 0 && a[i] == b[tot].v)
      b[tot].sum++;
    else {
      b[++tot].v = a[i];
      b[tot].sum = 1;
    }
    if (tot > 0 && b[tot].sum == k) tot--;
  }
  long long num = 0, num2 = 0, ans = 0;
  for (long long i = 1; i <= tot; ++i) num = num + b[i].sum;
  long long l = 1, r = tot;
  while (l < r && b[l].v == b[r].v && (b[l].sum + b[r].sum) % k == 0) {
    num2 += b[l].sum + b[r].sum;
    l++;
    r--;
  }
  if (l == r) {
    if (b[l].sum * m % k == 0) ans -= num2;
    ans += num * m - num2 * (m - 1) - b[l].sum * m / k * k;
  } else {
    if (b[l].v == b[r].v) num2 += (b[l].sum + b[r].sum) / k * k;
    ans = m * num - num2 * (m - 1);
  }
  printf("%I64d\n", ans);
}
