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;
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 || !i) return (long long)m * (long long)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 - 1) % 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 - 1) +
           (long long)q[i + 1][1] * (long long)(m - 1) % w;
  }
  return s * (long long)m - (long long)i * (long long)w * (long long)(m - 1);
}
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;
}
