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;
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() {
  int n, k, m, v;
  cin >> n >> k >> m;
  list<pair<int, int> > l;
  int ans = n * m;
  int 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++;
  }
  int boarders = 0;
  while (l.size() > 1 && l.front().first == l.back().first &&
         l.front().second + l.back().second >= k) {
    ans -= (m - 1) * k;
    boarders++;
    int 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;
}
