#include <bits/stdc++.h>
using namespace std;
set<int> s;
long long ans;
int i, j, k, n, m, a[510001], b[510001], w, t1, t2, q[510001][2];
long long calc() {
  int i, j, k;
  long long res, s;
  for (i = 1, k = 0; i <= n; i++) {
    if (!k || q[k][0] != b[i]) {
      q[++k][0] = b[i];
      q[k][1] = 1;
      continue;
    }
    if (++q[k][1] == w) k--;
  }
  for (i = 1, s = 0; i <= k; i++) s += q[i][1];
  for (i = 0;
       i < k && q[i + 1][0] == q[k - i][0] && q[i + 1][1] + q[k - i][1] == w;
       i++)
    ;
  if (m == 1) return s;
  if (i == k) {
    if (m % 2 == 0) return 0;
    return s;
  }
  if (i == k / 2) {
    if ((long long)q[i + 1][1] * (long long)m % w == 0) return 0;
    return s * (long long)m - (long long)i * (long long)w * (long long)(m - 1) -
           (long long)q[i + 1][1] * (long long)m +
           (long long)q[i + 1][1] * (long long)m % w;
  }
  res = s * (long long)m - (long long)i * (long long)w * (long long)(m - 1);
  if (q[i + 1][0] == q[k - i][0] && q[i + 1][1] + q[k - i][1] > w)
    res -= (long long)w * (long long)(m - 1);
  return res;
}
int main() {
  scanf("%d%d%d", &n, &w, &m);
  s.clear();
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i], s.insert(a[i]);
  if (s.size() == 1) return cout << (long long)m * (long long)n % w << endl, 0;
  ans = calc();
  cout << ans << endl;
  return 0;
}
