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;
const int maxn = 300005;
const double eps = 1e-10;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
pair<int, int> p[maxn];
int a[maxn];
int main() {
  int n = read();
  long long k = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  int tot = 0;
  for (int i = 1, num = 0; i <= n; i++) {
    if (a[i] != p[tot].first)
      p[++tot].first = a[i], p[tot].second = 1;
    else {
      (p[tot].second += 1) %= k;
      if (p[tot].second == 0) tot--;
    }
  }
  int pl = 1, pr = tot;
  long long ans = 0, a1 = 0, a2 = 0;
  for (int i = 1; i <= tot; i++) a1 += p[i].second;
  while (pl != pr) {
    if (p[pl].first == p[pr].first && (p[pl].second + p[pr].second) % k == 0)
      a2 += p[pl].second + p[pr].second, pl++, pr--;
    else
      break;
  }
  if (pl == pr) {
    ans = a1 * m - a2 * (m - 1) - m * p[pl].second / k * k;
    if ((m * p[pl].second) % k == 0) ans -= a2;
  } else {
    if (p[pl].first == p[pr].first) a2 += (p[pl].second + p[pr].second) / k * k;
    ans = a1 * m - a2 * (m - 1);
  }
  cout << ans;
}
