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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    if (c == '-') f = -1;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  return x;
}
int n, m, k, a[200050];
int st[200050], cnt[200050], tot;
long long ans;
inline void init() {
  n = read();
  k = read();
  m = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
}
inline void solve() {
  for (int i = 1; i <= n; ++i)
    if (tot && st[tot] == a[i]) {
      if (++cnt[tot] == k) --tot;
    } else {
      st[++tot] = a[i];
      cnt[tot] = 1;
    }
  for (int i = 1; i <= tot; ++i) ans += cnt[i];
  if (m == 1) return;
  int i = 0;
  long long dec = 0;
  for (; i < tot; ++i) {
    if (st[i + 1] != st[tot - i]) break;
    int t = cnt[i + 1] + cnt[tot - i];
    if (t >= k) dec += k;
    if (t != k) break;
  }
  if (i == tot) {
    if (!(m & 1)) ans = 0;
    return;
  }
  if (i >= (tot + 1 >> 1)) {
    if (!(m & 1)) ans -= dec;
    return;
  }
  ans *= m;
  ans -= dec * (m - 1);
  if ((tot & 1) && i == (tot - 1 >> 1)) {
    int t = tot + 1 >> 1;
    ans = (long long)cnt[t] * m % k;
    if (!ans) return;
    for (int i = 1; i <= tot; ++i)
      if (i ^ t) ans += cnt[i];
    return;
  }
}
int main() {
  init();
  solve();
  printf("%I64d\n", ans);
  return 0;
}
