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 N = 100005;
int a[N], s[N], f[N], n, k, m, top;
long long ans;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  if (k >= n) {
    bool flag = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] != a[i - 1]) flag = 0;
    if (flag)
      cout << (long long)n * m % k;
    else
      cout << (long long)n * m << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    s[++top] = a[i];
    if (top > 1 && s[top] == s[top - 1])
      f[top] = f[top - 1] + 1;
    else
      f[top] = 1;
    if (f[top] == k) top -= k;
  }
  int L = 1, R = top;
  while (s[L] == s[R] && L != R) {
    int l = L, r = R, cnt = 0;
    while (s[L] == s[l] && l < r && cnt < k) ++l, ++cnt;
    while (s[R] == s[r] && l < r && cnt < k) --r, ++cnt;
    if (cnt == k)
      L = l, R = r, ans += k;
    else
      break;
  }
  bool flag = 1;
  for (int i = L + 1; i <= R; i++)
    if (s[i] != s[i - 1]) flag = 0;
  if (flag)
    cout << ((long long)(R - L + 1) * m % k
                 ? (long long)(R - L + 1) * m % k + ans
                 : 0);
  else
    cout << ans + (long long)(R - L + 1) * m;
  return 0;
}
