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 INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
template <typename T, typename T2>
inline void _max(T &a, T2 b) {
  a = max((T)a, (T)b);
}
template <typename T, typename T2>
inline void _min(T &a, T2 b) {
  a = min((T)a, (T)b);
}
const int MAX = 2e5 + 10;
int n, k, m, a[MAX];
int l[MAX], r[MAX], len[MAX], v[MAX];
void clear() {}
void read() {
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
}
void solve() {
  long long rem = 1ll * n * m;
  set<pair<int, int>, greater<pair<int, int>>> s;
  int x = a[0], c = 0, ns = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != x) {
      len[ns] = c, v[ns] = x;
      l[ns] = ns - 1, r[ns] = ns + 1;
      s.insert({len[ns], ns});
      c = 0, ns++;
    }
    x = a[i], c++;
  }
  len[ns] = c, v[ns] = x;
  l[ns] = ns - 1, r[ns] = -1;
  s.insert({len[ns], ns});
  ns++;
  while (!s.empty() && s.begin()->first >= k) {
    auto it = s.begin();
    int tLen = it->first, id = it->second;
    s.erase(it);
    if (tLen != len[id]) int a = 3;
    rem -= tLen / k * k * 1ll * m;
    if (tLen % k)
      len[id] = tLen % k, s.insert({tLen % k, id});
    else {
      if (r[id] != -1) l[r[id]] = l[id];
      if (l[id] != -1) r[l[id]] = r[id];
      if (r[id] != -1 && l[id] != -1 && v[l[id]] == v[r[id]]) {
        int nid = l[id], nlen = len[l[id]] + len[r[id]];
        int nl = l[l[id]], nr = r[r[id]];
        s.erase({len[l[id]], l[id]}), s.erase({len[r[id]], r[id]}),
            s.insert({nlen, nid});
        r[nid] = nr, l[nid] = nl, len[nid] = nlen;
        if (nr != -1) l[nr] = nid;
        if (nl != -1) r[nl] = nid;
      }
    }
  }
  if (s.size() == 1)
    rem -= 1ll * s.begin()->first * m / k * k;
  else if (rem && m > 1) {
    int lid = ns - 1, rid = 0;
    for (auto &p : s) _min(lid, p.second), _max(rid, p.second);
    while (rid > lid && v[lid] == v[rid]) {
      int LEN = len[lid] + len[rid];
      rem -= 1ll * LEN / k * k * (m - 1);
      if (LEN % k) break;
      rid = l[rid], lid = r[lid];
    }
    if (lid == rid) {
      rem -= (1ll * len[lid] * m) / k * k;
      if (1ll * len[lid] * m % k == 0) {
        rid = l[rid], lid = r[lid];
        while (rid != -1 && lid != -1 && v[lid] == v[rid]) {
          int LEN = len[lid] + len[rid];
          rem -= LEN / k * k;
          if (LEN % k) break;
          rid = l[rid], lid = r[lid];
        }
      }
    }
  }
  printf("%lld\n", rem);
}
int main() {
  while (scanf("%d%d%d", &n, &k, &m) == 3) {
    clear();
    read();
    solve();
    return 0;
  }
  return 0;
}
