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