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;
vector<pair<int, int>> Q;
int val(long long x) {
  printf("%lld\n", x);
  return 0;
}
int main() {
  int n, k, m, i, QN, rem, delt, v;
  scanf("%d%d%d", &n, &k, &m);
  Q.clear();
  for (i = 0; i < n; i++) {
    scanf("%d", &v);
    if (Q.empty() || v != Q.back().first) {
      Q.push_back(make_pair(v, 1));
    } else
      Q.back().second++;
    while (Q.back().second >= k) {
      Q.back().second -= k;
    }
    if (Q.back().second == 0) Q.pop_back();
  }
  QN = Q.size();
  if (QN == 0) {
    return val(0);
  }
  rem = 0;
  for (i = 0; i < QN; i++) rem += Q[i].second;
  delt = 0;
  for (i = 0; i < QN;) {
    if (Q[i].first == Q[QN - 1 - i].first) {
      if ((Q[i].second + Q[QN - 1 - i].second) >= k) {
        delt++;
        if (Q[i].second + Q[QN - 1 - i].second == k) {
          i++;
        } else
          break;
      } else
        break;
    } else
      break;
  }
  if (i == QN) {
    if (m % 2 == 0) {
      return val(0);
    } else {
      return val(rem);
    }
  } else {
    if (i == QN - 1 - i) {
      long long tmp = Q[i].second * (long long)m % k;
      if (tmp == 0) {
        return val(0);
      } else {
        return val(rem - Q[i].second + tmp);
      }
    } else {
      long long tmp = m;
      return val(rem * tmp - (tmp - 1) * k * delt);
    }
  }
  return 0;
}
