#include <bits/stdc++.h>
using namespace std;
const long long _ = 1e2;
const long long maxn = 1e5 + _;
pair<long long, long long> a[maxn];
long long plen, len, id[maxn];
int main() {
  long long n, k, m, x;
  scanf("%lld%lld%lld", &n, &k, &m);
  plen = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &x);
    if (plen == 0 || a[plen].first != x)
      a[++plen] = make_pair(x, 1);
    else
      a[plen].second++;
  }
  long long now, nxt;
  long long s = 0;
  len = 0;
  for (long long i = 1; i <= plen; i = nxt) {
    now = i, nxt = i + 1;
    while (now > 0 && a[now].second >= k) {
      a[now].second %= k;
      if (a[now].second == 0) {
        if (len != 0)
          now = id[len], s -= a[id[len--]].second;
        else
          break;
        if (now > 0 && nxt <= plen && a[now].first == a[nxt].first)
          a[now].second += a[nxt].second, nxt++;
      }
    }
    if (a[now].second != 0) id[++len] = now, s += a[id[len]].second;
  }
  if (len == 0) {
    puts("0");
    return 0;
  }
  if (len == 1) {
    printf("%lld\n", (long long)a[id[len / 2 + 1]].second * m % k);
    return 0;
  }
  long long i;
  long long g = 0, u = 0;
  for (i = 1; i <= len / 2; i++) {
    if (a[id[i]].first == a[id[len - i + 1]].first) {
      long long num = (a[id[i]].second + a[id[len - i + 1]].second) % k;
      g += a[id[i]].second + a[id[len - i + 1]].second - num;
      if (num != 0) {
        printf("%lld\n", s * m - g * (m - 1));
        return 0;
      }
    } else {
      printf("%lld\n", s * m - g * (m - 1));
      return 0;
    }
  }
  if (len % 2 == 0)
    puts("0");
  else {
    if (a[id[len / 2 + 1]].second * m % k == 0)
      puts("0");
    else
      printf("%lld\n", s * m - g * (m - 1) -
                           (a[id[len / 2 + 1]].second * m -
                            a[id[len / 2 + 1]].second * m % k));
  }
  return 0;
}
