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;
long long a[100005];
pair<long long, long long> st[100005];
long long top, n, m, k, l, r, rec, rec2;
long long ans;
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) {
    if (!top || st[top].first != a[i])
      st[++top] = make_pair(a[i], 1);
    else
      st[top].second = (st[top].second + 1) % k;
    if (st[top].second == 0) top--;
  }
  for (long long i = 1; i <= top; i++) rec += st[i].second;
  l = 1, r = top;
  while (l < r && st[l].first == st[r].first &&
         (st[l].second + st[r].second) % k == 0) {
    rec2 += st[l].second + st[r].second;
    l++;
    r--;
  }
  if (l == r) {
    if (st[l].second * m % k == 0) ans -= rec2;
    ans += m * rec - rec2 * (m - 1) - (st[l].second * m / k * k);
  } else {
    if (st[l].first == st[r].first)
      rec2 += (st[l].second + st[r].second) / k * k;
    ans = m * rec - rec2 * (m - 1);
  }
  printf("%lld\n", ans);
  return 0;
}
