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>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, k, m;
void solve(std::istream &in, std::ostream &out) {
  in >> n >> k >> m;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) in >> a[i];
  vector<pair<int, int> > ve;
  for (int i = 1; i <= n;) {
    int j = i;
    while (j <= n && a[j] == a[i]) ++j;
    if ((j - i) % k > 0) ve.emplace_back(a[i], (j - i) % k);
    i = j;
  }
  if (ve.size() == 0) {
    out << "0\n";
    return;
  }
  int L = 0, R = ve.size() - 1;
  while (L < R && ve[L].first == ve[R].first &&
         ve[L].second + ve[R].second == k)
    ++L, --R;
  if (L == R)
    if (ve[L].second * m % k == 0)
      out << "0\n";
    else
      out << 1ll * ve[L].second * m % k + 1ll * k * L << '\n';
  else if (L > R)
    out << "0\n";
  else {
    long long int ans = 0;
    for (int i = L; i <= R; ++i) ans += ve[i].second;
    out << ans * m + 1ll * L * k << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve(cin, cout);
  return 0;
}
