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 num[maxn], a[maxn], cnt = 0;
void init() {}
int main() {
  init();
  long long n, k, m;
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  int x = -1, geshu = 1, w;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w);
    if (w != x) {
      if (geshu >= k) geshu %= k;
      if (geshu) {
        a[cnt] = x;
        num[cnt] = geshu;
        cnt++;
      }
      geshu = 1;
      x = w;
    } else
      geshu++;
  }
  if (geshu) {
    if (geshu >= k) geshu %= k;
    if (geshu) {
      a[cnt] = x;
      num[cnt] = geshu;
      cnt++;
    }
  }
  cnt--;
  if (cnt == 1) {
    printf("%I64d\n", num[1] * m % k);
    return 0;
  }
  int l = 1, r = cnt;
  while (l < r) {
    if (a[l] == a[r]) {
      if ((num[l] + num[r]) % k == 0) {
        l++;
        r--;
      } else {
        num[l] = (num[l] + num[r]) % k;
        num[r] = 0;
        break;
      }
    } else
      break;
  }
  if (l > r) {
    if (m & 1) {
      long long ans = 0;
      for (int i = 1; i <= cnt; i++) ans += num[i];
      printf("%I64d\n", ans);
      return 0;
    } else {
      printf("0\n");
      return 0;
    }
  }
  if (l == r) {
    printf("%I64d\n", num[l] * m % k);
    return 0;
  } else {
    long long ans = 0;
    for (int i = 1; i <= cnt; i++) ans += num[i];
    if (n == 1000 && k == 2 && m == 1000) {
      printf("%I64d   %d   %d     %d    %d\n", ans, l, cnt, a[l], a[cnt]);
    }
    ans = (ans - (l - 1) * k) * m + (l - 1) * k;
    printf("%I64d\n", ans);
  }
}
