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 = (int)1e5 + 5;
int arr[MAXN];
int n, k, m;
void solve() {
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
  }
  vector<pair<int, int> > S;
  for (int i = 1; i <= n; ++i) {
    if (!S.empty() && S.back().second == arr[i]) {
      if (++S.back().first == k) {
        S.pop_back();
      }
    } else {
      S.push_back(make_pair(1, arr[i]));
    }
  }
  int p = 0;
  while (p < S.size() && S[p].second == S[S.size() - p - 1].second &&
         S[p].first + S[S.size() - p - 1].first == k) {
    ++p;
  }
  if (p == S.size()) {
    if (m % 2) {
      long long ans = 0;
      for (auto it : S) {
        ans += it.first;
      }
      printf("%lld\n", ans);
      return;
    }
    printf("0\n");
    return;
  }
  if (S.size() % 2 && p == S.size() / 2) {
    int cur = (S[p].first * 1ll * m) % k;
    if (cur > 0) {
      long long ans = cur;
      for (int i = 0; i < S.size(); ++i) {
        if (i != p) {
          ans += S[i].first;
        }
      }
      printf("%lld\n", ans);
      return;
    } else {
      printf("0\n");
      return;
    }
  }
  long long ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    ans += S[i].first;
  }
  ans *= m;
  ans -= (m - 1ll) * k * p;
  if (S[p].second == S[S.size() - p - 1].second &&
      S[p].first + S[S.size() - p - 1].first >= k) {
    ans -= (m - 1ll) * k;
  }
  printf("%lld\n", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
