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;
int N, K, M;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> K >> M;
  vector<pair<long long, long long> > a;
  for (int i = 1; i <= N; ++i) {
    int x;
    cin >> x;
    if (a.empty()) {
      a.emplace_back(x, 1);
    } else if (a.back().first == x) {
      a.back().second++;
    } else {
      a.emplace_back(x, 1);
    }
    if (a.back().second == K) {
      a.pop_back();
    }
  }
  int n = a.size();
  int l = 0, r = n - 1;
  long long len1 = 0, len2 = 0, ret = 0;
  for (int i = 0; i < n; ++i) len1 += a[i].second;
  while (l < r && a[l].first == a[r].first &&
         (a[l].second + a[r].second) % K == 0) {
    len2 += a[l].second + a[r].second, ++l, --r;
  }
  if (l == r) {
    if (a[l].second * M % K == 0) {
      ret = len1 * M - len2 * M - (a[l].second * M / K * K);
    } else {
      ret = len1 * M - len2 * (M - 1) - (a[l].second * M / K * K);
    }
  } else {
    if (a[l].first == a[r].first) {
      len2 += (a[l].second + a[r].second) / K * K;
    }
    ret = len1 * M - len2 * (M - 1);
  }
  cout << ret << endl;
}
