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 N = 1e5 + 5;
int a[N], b[N], sz;
void solve() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  long long res = (long long)n * m;
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    if (!sz || a[sz - 1] != x) {
      a[sz] = x;
      b[sz] = 1;
      ++sz;
    } else {
      if (++b[sz - 1] == k) {
        res -= (long long)k * m;
        b[--sz] = 0;
      }
    }
  }
  int l = 0, r = sz - 1;
  for (; r > l && a[l] == a[r] && (b[l] + b[r] >= k); ++l, --r) {
    long long c = (b[l] + b[r]);
    res -= (c / k) * k * (m - 1);
    if (c % k) {
      printf("%lld\n", res);
      return;
    }
  }
  if (l == r) {
    res -= ((long long)b[l] * m / k) * k;
    if (((long long)b[l] * m) % k == 0) {
      for (--l, ++r; l >= 0 && r < sz; --l, ++r) {
        res -= ((b[l] + b[r]) / k) * (long long)k;
        if ((b[l] + b[r]) % k) break;
      }
    }
  }
  printf("%lld\n", res);
}
int main() {
  solve();
  return 0;
}
