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 = 1e5 + 5;
int n, m, k;
int a[N];
pair<int, int> s[N << 2];
int tot;
inline bool check() {
  int cnt = 0, now = -1;
  for (int i = (0); i < (tot); ++i) {
    if (s[i].second == now)
      ++cnt;
    else
      cnt = 1, now = s[i].second;
    if (cnt == k) return true;
  }
  return false;
}
bool del[N << 2];
inline void doit() {
  memset(del, 0, sizeof(del));
  int cnt = 0, now = -1;
  for (int i = (0); i < (tot); ++i) {
    if (s[i].second == now)
      ++cnt;
    else
      cnt = 1, now = s[i].second;
    if (cnt == k) {
      for (int j = (i - cnt + 1); j < (i + 1); ++j) del[j] = 1;
      cnt = 0;
    }
  }
  int t = 0;
  for (int i = (0); i < (tot); ++i)
    if (!del[i]) s[t++] = s[i];
  tot = t;
  return;
}
inline bool same() {
  for (int i = (0); i < (n - 1); ++i) {
    if (a[i] != a[i + 1]) return false;
  }
  return true;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  if (same()) {
    printf("%lld\n", (long long)n * m % k);
    return 0;
  }
  if (m & 1) {
    for (int i = (0); i < (3); ++i)
      for (int j = (0); j < (n); ++j) s[tot++] = make_pair(i, a[j]);
    while (check()) doit();
    int k0 = 0, k1 = 0, k2 = 0;
    for (int i = (0); i < (tot); ++i) {
      if (s[i].first == 0)
        ++k0;
      else if (s[i].first == 1)
        ++k1;
      else
        ++k2;
    }
    printf("%lld\n", (long long)(m - 2) * k1 + k0 + k2);
  } else {
    for (int i = (0); i < (4); ++i)
      for (int j = (0); j < (n); ++j) s[tot++] = make_pair(i, a[j]);
    while (check()) doit();
    int k0 = 0, k1 = 0, k2 = 0, k3 = 0;
    for (int i = (0); i < (tot); ++i) {
      if (s[i].first == 0)
        ++k0;
      else if (s[i].first == 1)
        ++k1;
      else if (s[i].first == 2)
        ++k2;
      else
        ++k3;
    }
    printf("%lld\n", (long long)(m - 2) * (k1 + k2) + k0 + k3);
  }
  return 0;
}
