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;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  long long m;
  cin >> n >> k >> m;
  deque<pair<int, int>> arr;
  int n2 = 0;
  for (int i = 0, prev = -1, freq = 0; i <= n; i++) {
    int val = -1;
    if (i < n) cin >> val;
    if (val != prev) {
      freq %= k;
      if (freq > 0) {
        arr.emplace_back(prev, freq);
        n2 += freq;
        prev = val;
      }
      if (prev == -1) prev = val;
      freq = 1;
    } else {
      freq++;
    }
  }
  long long ans = n2 * m;
  while (!arr.empty()) {
    if (arr.size() == 1) {
      long long tot = m * arr.front().second;
      if (tot % k == 0)
        ans = 0;
      else {
        ans -= (tot - (tot % k));
      }
      break;
    }
    if (arr.front().first != arr.back().first) break;
    int tot = arr.front().second + arr.back().second;
    ans -= (m - 1) * (tot - (tot % k));
    if (tot % k != 0) break;
    arr.pop_front();
    arr.pop_back();
  }
  cout << ans << '\n';
  return 0;
}
