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>
#pragma GCC optimize(3)
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
long long tot, n, m, k, x[100010], s[100010][2], cnt;
int main() {
  read(n);
  read(k);
  read(m);
  for (int i = 1; i <= n; i++) {
    read(x[i]);
    if (i == 1) {
      s[++cnt][0] = x[i];
      s[cnt][1] = 1;
      continue;
    }
    if (x[i] == x[i - 1]) {
      s[cnt][1]++;
      if (s[cnt][1] == k)
        ;
      cnt--;
    } else {
      s[++cnt][0] = x[i];
      s[cnt][1] = 1;
    }
  }
  for (int i = 1; i <= cnt; i++) tot += s[i][1];
  int head = 1, tail = n;
  while (head < tail && s[head][0] == s[tail][0]) {
    if ((s[head][1] + s[tail][1]) % k == 0) {
      head++;
      tail--;
    } else {
      s[head][1] = (s[head][1] + s[tail][1]) % k;
      s[tail][1] = 0;
      break;
    }
  }
  long long ans = 0;
  if (head < tail) {
    for (int i = head; i <= tail; i++) ans += s[i][1];
    ans *= (m - 1);
    ans += tot;
  } else {
    if ((s[head][1] * m) % k != 0) ans = tot + s[head][1] * (m - 1) % k;
  }
  writeln(ans);
  return 0;
}
