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 = 1e5 + 10;
int a[maxn], stack[maxn][2];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') flag = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int main() {
  int i, k, m, n;
  n = read();
  k = read();
  m = read();
  for (i = 1; i <= n; i++) a[i] = read();
  if (k > n) {
    int flag = 0;
    for (i = 2; i <= n; i++)
      if (a[i] != a[i - 1]) {
        flag = 1;
        break;
      }
    if (flag)
      printf("%lld\n", 1ll * n * m);
    else
      printf("%lld\n", 1ll * n * m % k);
    return 0;
  }
  int top = 0;
  for (i = 1; i <= n; i++) {
    stack[++top][0] = a[i];
    if (a[i] == a[i - 1] && top > 1)
      stack[top][1] = stack[top - 1][1] + 1;
    else
      stack[top][1] = 1;
    if (stack[top][1] >= k) top -= k;
  }
  int l = 1, r = top;
  long long ans = 0;
  while (stack[l][0] == stack[r][0] && l < r) {
    int tmpl = l, tmpr = r, cnt = 0;
    while (stack[tmpl][0] == stack[l][0] && l < r && cnt < k) tmpl++, cnt++;
    while (stack[tmpr][0] == stack[r][0] && l < r && cnt < k) tmpr--, cnt++;
    if (cnt == k)
      l = tmpl, r = tmpr, ans += 1ll * k;
    else
      break;
  }
  int flag = 0;
  for (i = l + 1; i <= r; i++)
    if (stack[i][0] != stack[i - 1][0]) {
      flag = 1;
      break;
    }
  if (!flag) {
    if ((r - l + 1) * m % k == 0)
      puts("0");
    else
      printf("%lld\n", 1ll * (r - l + 1) * m % k + ans);
  } else
    printf("%lld\n", ans + 1ll * (r - l + 1) * m);
  return 0;
}
