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;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n, m, k, a[100010], b[100010], stk[100010], top;
long long ans;
signed main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  int u = 0;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!top)
      stk[++top] = a[i], cnt++;
    else {
      if (stk[top] == a[i])
        cnt++;
      else
        cnt = 1;
      stk[++top] = a[i];
    }
    if (cnt == m) {
      top -= m;
      ans += m;
      cnt = 0;
      for (int j = top; j >= 0; j--)
        if (stk[j] != stk[top]) {
          cnt = top - j;
          break;
        }
    }
  }
  u = top;
  memcpy(b, stk, sizeof(b));
  int nnn = n;
  n = u;
  memcpy(a, b, sizeof(a));
  bool flag = 0;
  for (int i = 2; i <= n; i++)
    if (a[i] != a[1]) {
      flag = 1;
      break;
    }
  if (!flag) {
    cout << 1ll * nnn * k % m;
    return 0;
  }
  int l = 1, r = n;
  while (l <= r) {
    int x = l, y = r;
    if (a[l] != a[r]) break;
    while (a[x + 1] == a[l]) x++;
    while (a[y - 1] == a[r]) y--;
    if (x >= y) {
      ans += (1ll * k * (r - l + 1) / m) * m;
      if (1ll * k * (r - l + 1) % m == 0) ans += n - (r - l + 1);
      break;
    }
    if (x - l + 1 + r - y + 1 >= m) {
      ans += 1ll * (k - 1) * m;
      if (x - l + 1 + r - y + 1 > m)
        break;
      else if (m == (x - l + 1 + r - y + 1))
        l = x + 1, r = y - 1;
      else
        break;
    } else
      break;
  }
  ans = 1ll * nnn * k - ans;
  cout << ans;
  return 0;
}
