#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<long long> input(n);
  for (long long i = 0; i < n; ++i) cin >> input[i];
  long long count = 0;
  list<pair<long long, long long>> counts;
  long long currentValue = input[0];
  for (long long i = 0; i < input.size(); ++i) {
    if (input[i] == currentValue)
      count++;
    else {
      counts.push_back(pair<long long, long long>(currentValue, count % k));
      count = 1;
      currentValue = input[i];
    }
  }
  counts.push_back(pair<long long, long long>(currentValue, count % k));
  auto current = counts.begin();
  while (current != counts.end()) {
    if (current->second == 0) {
      current = counts.erase(current);
      if (current != counts.begin()) --current;
    } else if ((next(current)) != counts.end() &&
               (next(current)->first == current->first)) {
      current->second += next(current)->second;
      current->second %= k;
      counts.erase(next(current));
    } else {
      current++;
    }
  }
  long long ans = 0;
  if (counts.size() == 0) {
    ans = 0;
  } else if (counts.size() == 1) {
    ans = counts.begin()->second;
    ans = (ans * m) % k;
  } else {
    long long erased = 0;
    auto l = counts.begin();
    auto r = counts.end();
    r--;
    while (counts.size() & 1 ? l != r : next(l) != r) {
      if (l->first == r->first && (l->second + r->second == k)) {
        ++l;
        --r;
        erased += k;
      } else {
        if (l->first == r->first) {
          erased += ((l->second + r->second) / k) * k;
          l->second -= ((l->second + r->second) / k) * k;
        }
        break;
      }
    }
    if (l == r) {
      ans = (l->second * m) % k;
      if (ans != 0) {
        ans += erased;
      }
    } else {
      long long multiple = 0;
      auto k = l;
      while (k != next(r)) {
        multiple += k->second;
        k++;
      }
      ans = erased + m * multiple;
    }
  }
  cout << ans << endl;
  return 0;
}
