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;
pair<long long, long long> M[1000000 + 9];
long long ar[1000000 + 9];
int main() {
  long long i, j = 0, k, l, n, m, tot = 0, temp, siz, flag, ans, test, curr,
               ind, x, q, now_xor, r, pos;
  int t1;
  char ch;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &t1);
    ar[i] = t1;
  }
  pos = 0;
  ans = 0;
  for (i = 1; i <= n; i++) {
    temp = 0;
    for (j = i; j <= n; j++) {
      if (ar[j] == ar[i])
        temp++;
      else
        break;
    }
    if (temp % k) M[++pos] = make_pair(ar[i], temp % k);
    i = j - 1;
    ans += (temp % k);
  }
  if (pos == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (pos == 1) {
    cout << (ans * m) % k << endl;
    return 0;
  }
  ans *= m;
  n = pos;
  flag = 0;
  for (i = 1; i <= n; i++) {
    if (M[i].first == M[n - i + 1].first &&
        !((M[i].second + M[n - i + 1].second) % k))
      continue;
    flag = 1;
  }
  if (flag == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    if (M[i] == M[n - i + 1] && !((M[i].second + M[n - i + 1].second) % k)) {
      temp = M[i].second + M[n - i + 1].second;
      temp /= k;
      temp *= k;
      ans -= M[i].second * temp * (m - 1);
    } else {
      temp = M[i].second + M[n - i + 1].second;
      temp /= k;
      temp *= k;
      if (M[i].first == M[n - i + 1].first &&
          M[i].second + M[n - i + 1].second >= k)
        ans -= (m - 1) * temp;
      break;
    }
  }
  cout << ans << endl;
}
