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 MAX_N = 100000;
pair<int, int> as[MAX_N], bs[MAX_N], cs[MAX_N];
void printps(pair<int, int> ps[], int i0, int j0) {
  for (int i = i0; i < j0; i++) printf("%d*%d ", ps[i].first, ps[i].second);
  putchar('\n');
}
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  long long c = 0, s = (long long)n * m;
  int l = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    if (l > 0 && as[l - 1].first == ai) {
      if (++as[l - 1].second == k) c += (long long)m * k, l--;
    } else
      as[l++] = pair<int, int>(ai, 1);
  }
  if (l == 0 || m == 1) {
    printf("%lld\n", s - c);
    return 0;
  }
  copy(as, as + l, bs);
  copy(as, as + l, cs);
  int i0 = 0, j0 = l;
  if (m > 2) {
    while (i0 + 1 < j0 && as[i0].first == as[j0 - 1].first) {
      long long c0 = as[i0].second + as[j0 - 1].second;
      c += (long long)(m - 1) * (c0 / k * k);
      int r = c0 % k;
      as[j0 - 1].second = bs[j0 - 1].second = 0;
      j0--;
      as[i0].second = cs[i0].second = r;
      if (r == 0)
        i0++;
      else
        break;
    }
    if (i0 + 1 == j0) {
      long long c0 = (long long)(m - 2) * as[i0].second;
      c += c0 / k * k;
      int r = c0 % k;
      as[i0].second = 0;
      cs[i0].second += r;
    }
  }
  while (j0 > 0 && i0 < l && bs[j0 - 1].first == cs[i0].first) {
    long long c0 = (long long)bs[j0 - 1].second + cs[i0].second;
    c += c0 / k * k;
    int r = c0 % k;
    i0++, j0--;
    if (r > 0) break;
  }
  printf("%lld\n", (long long)n * m - c);
  return 0;
}
