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 = 100005;
int a[maxn];
int sst[maxn];
long long sta[maxn];
int main() {
  int n, m;
  long long k;
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int tot = 0;
  for (int i = 0; i < n; i++) {
    if (!tot || sst[tot] != a[i]) {
      sst[++tot] = a[i];
      sta[tot] = 1;
    } else {
      sta[tot]++;
    }
    if (sta[tot] == k) tot--;
  }
  long long sum1 = 0;
  for (int i = 1; i <= tot; i++) {
    sum1 += sta[i];
  }
  int l = 1, r = tot;
  while (l < r && sst[l] == sst[r]) {
    sta[l] = (sta[l] + sta[r]) % k;
    sta[r] = 0;
    if (sta[l] != 0) break;
    l++, r--;
  }
  long long sum2 = 0;
  for (int i = l; i <= r; i++) {
    sum2 += sta[i];
  }
  long long ans = 0;
  if (l < r)
    ans = sum2 * (m - 1) + sum1;
  else
    ans = ((sta[l] * m) % k == 0 ? 0 : (sum1 + sta[l] * m % k - sta[l]));
  cout << ans << endl;
  return 0;
}
