#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long n, k, m, p[N], rnk[N], sz[N], a[N];
int prv[N], nxt[N], base[N];
set<int> st;
void init(int n) {
  for (int i = 0; i < n; i++)
    p[i] = i, sz[i] = 1, prv[i] = i - 1, nxt[i] = i + 1;
}
int _find(int x) { return (p[x] == x ? x : p[x] = _find(p[x])); }
int mrg(int x, int y) {
  if (a[x] != a[y]) return -1;
  x = _find(x);
  y = _find(y);
  if (x == y) return -1;
  if (rnk[x] > rnk[y]) swap(x, y);
  p[x] = y;
  rnk[y] += rnk[x] == rnk[y];
  sz[y] += sz[x];
  nxt[y] = max(nxt[y], nxt[x]);
  prv[y] = min(prv[y], prv[x]);
  if (st.count(x)) st.erase(x);
  if (sz[y] % k == 0)
    st.insert(y);
  else if (st.count(y))
    st.erase(y);
  return y;
}
int main() {
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
  init(n);
  for (int i = 0; i < n; i++) {
    if (i) mrg(i - 1, i);
    if (i + 1 < n) mrg(i, i + 1);
  }
  for (int i = 0; i < n; i++)
    if (p[i] == i && sz[i] % k == 0) st.insert(i);
  while (!st.empty()) {
    int i = *st.begin();
    st.erase(st.begin());
    if (prv[i] != -1) nxt[_find(prv[i])] = nxt[i];
    if (nxt[i] != n) prv[_find(nxt[i])] = prv[i];
    if (prv[i] != -1 && nxt[i] != n) mrg(prv[i], nxt[i]);
  }
  vector<pair<long long, long long> > v;
  long long ans = 0;
  for (int i = 0; i < n; i++)
    if (i == p[i]) {
      ans += (sz[i] - sz[i] % k) * m;
      if (sz[i] % k) v.push_back({a[i], sz[i] % k});
    }
  if (!v.empty()) {
    for (int i = 0, j = v.size() - 1; i < v.size(); i++, j--) {
      if (v[i].first != v[j].first) break;
      long long sum = 0;
      if (i == j)
        sum = v[i].second * m;
      else
        sum = v[i].second + v[j].second;
      long long res = (sum / k) * k;
      if (i < j)
        ans += res * (m - 1);
      else
        ans += res;
      if (sum % k != 0) break;
    }
  }
  printf("%I64d\n", n * m - ans);
  return 0;
}
