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;
const int dim = 500005;
int n, m, k;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> m;
  long long total = 1LL * n * m;
  list<pair<int, int> > v;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    if (v.empty() || v.back().first != x)
      v.push_back({x, 1});
    else
      v.back().second++;
  }
  list<pair<int, int> > w;
  for (auto it : v) {
    if (w.empty()) {
      if (it.second % k == 0) {
        total -= 1LL * it.second * m;
      } else {
        w.push_back({it.first, it.second % k});
        total -= 1LL * (it.second - it.second % k) * m;
      }
      continue;
    }
    if (w.back().first != it.first) {
      if (it.second % k == 0) {
        total -= 1LL * it.second * m;
      } else {
        w.push_back({it.first, it.second % k});
        total -= 1LL * (it.second - it.second % k) * m;
      }
      continue;
    }
    w.back().second += it.second;
    if (w.back().second % k == 0) {
      total -= 1LL * w.back().second * m;
      w.pop_back();
    } else {
      total -= 1LL * (w.back().second - w.back().second % k) * m;
      w.back().second %= k;
    }
  }
  v = w;
  w.clear();
  while (!v.empty()) {
    if (v.size() == 1) {
      total -= (1LL * m * v.back().second - 1LL * m * v.back().second % k);
      if (1LL * m * v.back().second % k == 0) v.pop_back();
      break;
    }
    if (v.front().first != v.back().first) break;
    int s = v.front().second + v.back().second;
    if (s % k != 0) {
      total -= 1LL * (m - 1) * (s - s % k);
      break;
    }
    total -= 1LL * (m - 1) * s;
    w.push_back(v.back());
    w.push_front(v.front());
    v.pop_back();
    v.pop_front();
  }
  if (v.empty()) {
    v = w;
    if (!v.empty()) {
      auto it2 = v.begin();
      auto it1 = it2++;
      while (it1->first != it2->first) it1++, it2++;
      while (true) {
        int s = it1->second + it2->second;
        if (s % k) {
          total -= s - s % k;
          break;
        } else {
          total -= s;
          it2++;
          if (it2 == v.end()) break;
          it1--;
        }
      }
    }
  }
  cout << total << '\n';
  return 0;
}
