#include <bits/stdc++.h>
using namespace std;
long long n, k, m, i, j, a, b, l, ans;
vector<pair<long long, long long> > c;
int main() {
  scanf("%I64d %I64d %I64d", &n, &k, &m);
  ans = n * m;
  j = 1;
  scanf("%I64d", &a);
  for (i = 1; i < n; i++) {
    scanf("%I64d", &b);
    if (b == a)
      j++;
    else {
      if (c.size() > 0 && c[c.size() - 1].first == a) {
        j += c[c.size() - 1].second;
        ans -= (j - (j % k)) * m;
        j = j % k;
        if (j == 0)
          c.pop_back();
        else
          c[c.size() - 1].second = j;
      } else {
        ans -= (j - (j % k)) * m;
        j = j % k;
        if (j != 0) c.push_back(make_pair((a), (j)));
      }
      a = b;
      j = 1;
    }
  }
  if (c.size() > 0 && c[c.size() - 1].first == a) {
    j += c[c.size() - 1].second;
    ans -= (j - (j % k)) * m;
    j = j % k;
    if (j == 0)
      c.pop_back();
    else
      c[c.size() - 1].second = j;
  } else {
    ans -= (j - (j % k)) * m;
    j = j % k;
    if (j != 0) c.push_back(make_pair((a), (j)));
  }
  if (j == n) {
    ans = ans % k;
    printf("%I64d\n", ans);
    return 0;
  }
  if (c.size() == 0) {
    ans = 0;
    printf("%I64d\n", ans);
    return 0;
  }
  i = 0;
  j = c.size() - 1;
  while (true) {
    if (c[i].first != c[j].first) break;
    if (i == j) {
      if ((c[i].second * m) % k != 0)
        ans -= ((c[i].second * m) - ((c[i].second * m) % k));
      else
        ans = 0;
      break;
    }
    l = c[i].second + c[j].second;
    ans -= (l - (l % k)) * (m - 1);
    if (l % k != 0) break;
    i++;
    j--;
  }
  printf("%I64d\n", ans);
  return 0;
}
