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 n, k, m;
long long res;
int a[Maxn];
vector<pair<long long, int> > my;
long long Add(vector<pair<long long, int> > &seq, pair<long long, int> p) {
  long long res = 0;
  res += p.first / k * k;
  p.first %= k;
  if (p.first == 0) return res;
  if (seq.empty() || seq.back().second != p.second)
    seq.push_back(p);
  else {
    seq.back().first += p.first;
    res += seq.back().first / k * k;
    seq.back().first %= k;
    if (seq.back().first == 0) seq.pop_back();
  }
  return res;
}
long long Get(vector<pair<long long, int> > &A,
              vector<pair<long long, int> > B) {
  vector<pair<long long, int> > tmp = A;
  long long res = 0;
  for (int i = 0; i < B.size(); i++) res += Add(tmp, B[i]);
  if (tmp.size() <= 2 * Maxn)
    A = tmp;
  else {
    A.clear();
    for (int i = 0; i < Maxn; i++) A.push_back(tmp[i]);
    for (int i = Maxn; i > 0; i--) A.push_back(tmp[int(tmp.size()) - i]);
  }
  return res;
}
int main() {
  scanf("%d %d %d", &n, &k, &m);
  int tk = m / 2;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  long long cur = 0;
  for (int i = 0, j; i < n; i = j) {
    j = i;
    while (j < n && a[i] == a[j]) j++;
    cur += Add(my, pair<long long, int>(j - i, a[i]));
  }
  vector<pair<long long, int> > R;
  int savm = m;
  while (m) {
    if (m & 1) res += cur + Get(R, my);
    m >>= 1;
    cur = 2 * cur + Get(my, my);
  }
  cout << long long(n) * savm - res << endl;
  return 0;
}
