#include <bits/stdc++.h>
using namespace std;
int n, k, m, cur;
long long a[200005][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;
}
