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;
int n, m, q, x[100010], a[100010], b[100010], t;
long long p;
int main() {
  int i, j, k, l, r;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) scanf("%d", &x[i]);
  for (i = 1; i <= n; i++) {
    if (!t || x[i] != a[t]) {
      a[++t] = x[i];
      b[t] = 1;
    } else {
      b[t]++;
      if (b[t] == m) t--;
    }
  }
  if (t == 0)
    printf("0\n");
  else {
    n = t;
    for (i = 1, j = 0; i <= n; i++) j += b[i];
    for (i = 1, k = 0; i < n + 1 - i; i++)
      if (a[i] == a[n + 1 - i] && b[i] + b[n + 1 - i] == m)
        k += m;
      else
        break;
    if (i < n + 1 - i) {
      if (a[i] == a[n + 1 - i] && b[i] + b[n + 1 - i] > m) k += m;
      p = (long long)j * q - (long long)k * (q - 1);
    } else {
      p = (long long)b[i] * q % m;
      if (p) p += j - b[i];
    }
    cout << p;
  }
  return 0;
}
