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;
long long a[101000], c[101000], num[101000];
int main() {
  long long n, cir, m;
  while (scanf("%lld%lld%lld", &n, &cir, &m) != EOF) {
    long long cnt = 0;
    for (long long i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      if (a[i] != c[cnt]) {
        c[++cnt] = a[i];
        num[cnt] = 1;
      } else {
        num[cnt]++;
        if (num[cnt] == cir) cnt--;
      }
    }
    if (!cnt) {
      printf("0\n");
      continue;
    }
    long long sum = 0;
    for (long long i = 1; i <= cnt; i++) sum += num[i];
    long long k, k1;
    long long s = 0;
    for (k = 1, k1 = cnt + 1 - k; k < k1; k++, k1--) {
      if (c[k] == c[k1] && num[k] + num[k1] == cir)
        s = s + cir;
      else
        break;
    }
    if (k < k1) {
      if (num[k] + num[k1] > cir) s = s + cir;
      printf("%lld\n", sum * m - s * (m - 1));
    } else if (k == k1) {
      if (m == 1)
        cout << sum << endl;
      else
        printf("%lld\n", (num[k] * m) % cir);
    }
  }
  return 0;
}
