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 maxn = 1e5 + 7;
int s[maxn][2], B[maxn];
int main() {
  int n;
  long long k, m;
  scanf("%d%lld%lld", &n, &k, &m);
  long long ans = n * m, tol = 0;
  int top = 0, x, R = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (!top || s[top][0] != x) {
      s[++top][0] = x;
      s[top][1] = 1;
    } else {
      s[top][1]++;
    }
    if (s[top][1] == k) {
      tol += k * m;
      top--;
    }
  }
  for (int i = 1; i <= top; i++) {
    for (int j = 0; j < s[i][1]; j++) {
      B[++R] = s[i][0];
    }
  }
  int l = 1, r = R;
  while (l <= r) {
    if (B[l] != B[r]) break;
    long long cnt = 0;
    while (B[l] == B[r] && l <= r) {
      cnt++;
      r--;
    }
    r++;
    while (B[l] == B[r] && l <= r) {
      cnt++;
      l++;
    }
    l--;
    if (l == r) {
      cnt--;
    }
    if (cnt % k != 0 && l != r) {
      tol += (cnt / k) * (m - 1) * k;
      break;
    }
    if (cnt % k != 0 && l == r) {
      tol += cnt * m / k * k;
      if (cnt * m % k == 0) {
        tol = ans;
      }
      break;
    }
    if (cnt % k == 0) {
      tol += cnt * (m - 1);
      if (l == r) {
        tol = ans;
        break;
      }
      l++, r--;
    }
  }
  printf("%lld\n", ans - tol);
  return 0;
}
