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 maxn = 1e5 + 7;
long long top, n, m, num, l, r, rec, rec2, ans, k;
long long a[maxn];
pair<int, int> ps[maxn];
int main() {
  cin >> 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 || ps[top].first != a[i])
      ps[++top] = make_pair(a[i], 1);
    else
      ps[top].second = (ps[top].second + 1) % k;
    if (ps[top].second == 0) --top;
  }
  for (long long i = 1; i <= top; ++i) rec += ps[i].second;
  l = 1, r = top;
  while (l < r && ps[l].first == ps[r].first &&
         (ps[l].second + ps[r].second) % k == 0) {
    rec2 += ps[l].second + ps[r].second;
    l++;
    r--;
  }
  if (l == r) {
    if (ps[l].second * m % k == 0) ans -= rec2;
    ans += m * rec - rec2 * (m - 1) - (ps[l].second * m / k * k);
  } else {
    if (ps[l].first == ps[r].first)
      rec2 += (ps[l].second + ps[r].second) / k * k;
    ans = m * rec - rec2 * (m - 1);
  }
  cout << ans << endl;
  return 0;
}
