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;
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 (st.count(y)) st.erase(y);
  if (sz[y] % k == 0) st.insert(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());
    i = _find(i);
    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;
}
