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>
int main() {
  int n, k, m;
  std::cin >> n >> k >> m;
  int a[100010];
  bool isSame = true;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    if (a[i] != a[0]) isSame = false;
  }
  if (isSame) {
    std::cout << (n * 1LL * m) % k;
    return 0;
  }
  std::vector<std::pair<int, int> > blocks;
  blocks.push_back(std::make_pair(a[0], 1));
  int lastBlock = 0;
  long long int remaining = n * 1LL * m;
  for (int i = 1; i < n; ++i) {
    if (a[i] == blocks[lastBlock].first && lastBlock != -1) {
      ++blocks[lastBlock].second;
      if (blocks[lastBlock].second >= k) {
        remaining -= m * k;
        blocks.pop_back();
        --lastBlock;
      }
    } else {
      ++lastBlock;
      blocks.push_back(std::make_pair(a[i], 1));
    }
  }
  int firstBlock = 0;
  std::vector<std::pair<int, int> > leftSide, rightSide;
  while (firstBlock < lastBlock &&
         blocks[lastBlock].first == blocks[firstBlock].first &&
         (blocks[lastBlock].second + blocks[firstBlock].second >= k)) {
    remaining -= (m - 1) * k;
    leftSide.push_back(blocks[firstBlock]);
    rightSide.push_back(blocks[lastBlock]);
    ++firstBlock;
    --lastBlock;
    if (blocks[lastBlock].second + blocks[firstBlock].second != k) break;
  }
  if (firstBlock < lastBlock) {
    std::cout << remaining;
  } else if (firstBlock == lastBlock) {
    remaining -= ((blocks[firstBlock].second * 1LL * m) / k) * k;
    std::cout << remaining;
  } else {
    for (int i = rightSide.size() - 1; i >= 0; --i) {
      remaining -= k;
      if (rightSide[i].second + leftSide[i].second != k) break;
    }
    std::cout << remaining;
  }
}
