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 INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 1e5 + 10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline void read(T& num) {
  bool start = false, neg = false;
  char c;
  num = 0;
  while ((c = getchar()) != EOF) {
    if (c == '-')
      start = neg = true;
    else if (c >= '0' && c <= '9') {
      start = true;
      num = num * 10 + c - '0';
    } else if (start)
      break;
  }
  if (neg) num = -num;
}
inline long long powMM(long long a, long long b, long long M) {
  long long ret = 1;
  a %= M;
  while (b) {
    if (b & 1) ret = ret * a % M;
    b >>= 1;
    a = a * a % M;
  }
  return ret;
}
void open() { freopen("out.txt", "w", stdout); }
int n, ge;
long long k, m;
vector<int> a, b, tem;
long long pre[MAX], suf[MAX];
long long an, cnt;
long long solve(int l, int r, long long tot) {
  long long re = 0;
  if (l > r) return 0;
  long long len = (r - l + 1);
  long long tot_len = tot * 1LL * len;
  if (a[r] != a[l])
    return 0;
  else {
    if (pre[r] >= len)
      return tot_len / k * k;
    else {
      long long qian = min(pre[r], len);
      long long hou = min(suf[l], len);
      if (qian + hou < k) return 0;
      long long ge = (qian + hou) / k;
      long long x = (qian + hou) % k;
      re = ge * k * (tot - 1LL);
      long long nl, nr;
      nl = l + hou, nr = r - qian + x;
      long long lin = solve(nl, nr, tot);
      re += lin;
      if (lin == (nr - nl + 1LL) * tot) re += ge * k;
      return re;
    }
  }
}
int now, last = -1;
int main() {
  scanf("%d%I64d%I64d", &n, &k, &m);
  a.push_back(-1);
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (tmp != last) now = 0;
    a.push_back(tmp);
    ++now;
    tem.push_back(now);
    if (now == k) {
      cnt++;
      a.resize(a.size() - k);
      tem.resize(tem.size() - k);
      now = tem.empty() ? 0 : tem.back();
      last = (a.size() == 1) ? -1 : a.back();
    } else
      last = tmp;
  }
  ge = a.size() - 1;
  pre[1] = 1;
  suf[ge] = 1;
  for (int i = 2; i <= ge; i++) {
    if (a[i] == a[i - 1])
      pre[i] = pre[i - 1] + 1;
    else
      pre[i] = 1;
  }
  for (int i = ge - 1; i >= 1; i--) {
    if (a[i] == a[i + 1])
      suf[i] = suf[i + 1] + 1;
    else
      suf[i] = 1;
  }
  an = cnt * m * k;
  an += solve(1, ge, m);
  printf("%I64d\n", (long long)n * m - an);
  return 0;
}
