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;
struct th {
  int num[400005];
  long long tms[400005];
  long long ans;
  int len;
  th() { memset(num, 0, sizeof(num)), memset(tms, 0, sizeof(tms)), ans = 0; }
} p[40];
int n, k, m;
void otp(int a) {
  cout << "OTP" << a << endl;
  for (int i = 1; i <= p[a].len; i++) {
    if (!p[a].tms[i]) break;
    cout << p[a].num[i] << " " << p[a].tms[i] << endl;
  }
  cout << endl;
  cout << p[a].ans << endl << endl;
}
long long tm[400005];
int nm[400005];
void upd(int a) {
  int cnt = 0;
  for (int i = 1; i <= p[a].len; i++)
    if (cnt && nm[cnt] == p[a].num[i]) {
      tm[cnt] += p[a].tms[i];
      if (tm[cnt] >= k) p[a].ans += (tm[cnt] / k) * k, tm[cnt] %= k;
      if (!tm[cnt]) cnt--;
    } else {
      if (p[a].tms[i]) cnt++, tm[cnt] = p[a].tms[i], nm[cnt] = p[a].num[i];
    }
  if (cnt >= 2 * n) {
    for (int i = 1; i <= n; i++)
      p[a].num[i] = nm[i], p[a].num[i + n] = nm[i + cnt - n],
      p[a].tms[i] = tm[i], p[a].tms[i + n] = tm[i + cnt - n];
    p[a].len = 2 * n;
  } else {
    p[a].len = cnt;
    for (int i = 1; i <= cnt; i++) p[a].num[i] = nm[i], p[a].tms[i] = tm[i];
  }
}
void lk(int a, int b, int c) {
  for (int i = 1; i <= p[a].len; i++)
    p[c].num[i] = p[a].num[i], p[c].tms[i] = p[a].tms[i];
  int pl = p[a].len;
  for (int i = 1; i <= p[b].len; i++)
    p[c].num[i + pl] = p[b].num[i], p[c].tms[i + pl] = p[b].tms[i];
  p[c].ans = p[a].ans + p[b].ans;
  p[c].len = p[a].len + p[b].len;
  upd(c);
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  long long ans = n * (long long)m;
  for (int i = 1; i <= n; i++) scanf("%d", &p[0].num[i]), p[0].tms[i] = 1;
  p[0].len = n;
  upd(0);
  for (int i = 1; i < 31; i++) lk(i - 1, i - 1, i);
  for (int i = 0; i < 31; i++) {
    if (m & 1) lk(35, i, 35);
    m >>= 1;
    if (!m) break;
  }
  ans -= p[35].ans;
  printf("%I64d\n", ans);
  return 0;
}
