#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool Max(T1& a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool Min(T1& a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 200001, inf = 1e9;
void solve() {
  long long n, k, m, v;
  cin >> n >> k >> m;
  list<pair<int, int> > l;
  long long ans = n * m;
  long long last = 0;
  while (n--) {
    cin >> v;
    if (v == last)
      l.back().second++;
    else {
      l.push_back({v, 1});
      last = v;
    }
  }
  auto it = l.begin();
  while (it != l.end()) {
    if (it->second >= k) {
      it->second -= k;
      ans -= k * m;
      if (it->second == 0) {
        it = l.erase(it);
        if (it != l.begin() && it != l.end()) {
          auto it2 = it;
          it2--;
          if (it->first == it2->first) {
            it2->second += it->second;
            l.erase(it);
            it = it2;
          }
        }
      }
    } else
      it++;
  }
  long long boarders = 0;
  while (l.size() > 1 && l.front().first == l.back().first &&
         l.front().second + l.back().second >= k) {
    ans -= (m - 1) * k;
    boarders++;
    long long rem = l.front().second + l.back().second - k;
    l.erase(l.begin());
    if (rem > 0) {
      break;
    }
    l.erase(--l.end());
  }
  if (l.size() == 1) {
    ans -= l.front().second * m / k * k;
    if (l.front().second * m % k == 0) {
      ans -= boarders * k;
    }
  }
  cout << ans << '\n';
}
void init() {}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  init();
  int TC = 1;
  for (int TI = 1; TI <= (TC); ++TI) {
    solve();
  }
  return 0;
}
