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 <class T>
int collapse(T &a, int k) {
  int i = 0, o = 0;
  int ans = 0;
  while (i < a.size()) {
    int val = a[i];
    int cnt = 1;
    while (i + cnt < a.size() && a[i + cnt] == val) {
      ++cnt;
    }
    i += cnt;
    ans += cnt / k * k;
    cnt %= k;
    while (cnt--) {
      a[o++] = val;
    }
  }
  a.resize(o);
  return ans;
}
void solve() {
  int n, k, m;
  cin >> n >> k >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long ans = n * 1ll * m;
  ans -= collapse(a, k) * 1ll * m;
  deque<int> mid(a.begin(), a.end());
  size_t prefix = a.size(), suffix = a.size();
  long long add = 0;
  while (mid.size() && mid.front() == mid.back()) {
    int val = mid.front();
    int fc = 1, bc = 1;
    while (fc < mid.size() && mid[fc] == val) ++fc;
    while (bc < mid.size() && mid[mid.size() - 1 - bc] == val) ++bc;
    if (fc == mid.size()) {
      add = fc * 1ll * (m - 2);
      while (prefix > 0 && a[prefix - 1] == val) {
        --prefix;
        ++add;
      }
      while (suffix > 0 && a[a.size() - suffix] == val) {
        --suffix;
        ++add;
      }
      mid.clear();
      continue;
    }
    if ((fc + bc) % k != 0) {
      int cnt = (fc + bc) / k * k;
      ans -= cnt * 1ll * (m - 1);
      cout << ans << endl;
      return;
    }
    prefix -= bc;
    suffix -= fc;
    ans -= (fc + bc) * 1ll * (m - 1);
    while (bc--) mid.pop_back();
    while (fc--) mid.pop_front();
  }
  ans -= add / k * k;
  if (add % k != 0 || mid.size()) {
    cout << ans << endl;
    return;
  }
  deque<int> l(a.begin(), a.begin() + prefix);
  deque<int> r(a.begin() + a.size() - suffix, a.end());
  while (l.size() && r.size() && l.back() == r.front()) {
    int val = l.back();
    int lc = 1, rc = 1;
    while (lc < l.size() && l[l.size() - 1 - lc] == val) ++lc;
    while (rc < r.size() && l[rc] == val) ++rc;
    ans -= (lc + rc) / k * k;
    if ((lc + rc) % k != 0) break;
    while (lc--) l.pop_back();
    while (rc--) r.pop_front();
  }
  ans -= collapse(l, k);
  ans -= collapse(r, k);
  cout << ans << endl;
}
int main() {
  srand(132456);
  solve();
  return 0;
}
