#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int N, K, M;
pair<long long, deque<pair<int, long long>>> get(
    const deque<pair<int, long long>> d) {
  long long result = 0;
  deque<pair<int, long long>> r;
  for (auto p : d) {
    if (r.empty() || r.back().first != p.first) r.push_back({p.first, 0});
    r.back().second += p.second;
    result += r.back().second / K;
    r.back().second %= K;
    if (!r.back().second) r.pop_back();
  }
  return make_pair(result, r);
}
int main() {
  scanf("%d%d%d", &N, &K, &M);
  deque<pair<int, long long>> A;
  for (int i = 0; i < (N); ++i) {
    int a;
    scanf("%d", &a);
    A.push_back({a, 1});
  }
  auto p = get(A);
  A = p.second;
  long long result = p.first * M;
  if (M == 1) {
    cout << N * (long long)M - result * (long long)K << endl;
    return 0;
  } else if (A.size() == 1) {
    result += A[0].second * M / K;
    cout << N * (long long)M - result * (long long)K << endl;
    return 0;
  }
  deque<pair<int, long long>> first, last;
  while (A.size() >= 2) {
    if (A.back().first != A.front().first) break;
    first.push_back(A.front());
    last.push_front(A.back());
    result += (A.back().second + A.front().second) / K * (long long)(M - 1);
    A.back().second += A.front().second;
    A.back().second %= K;
    A.pop_front();
    if (!A.back().second) A.pop_back();
  }
  if (A.size() == 1) {
    first.push_back({A[0].first, A[0].second * M});
    first.insert(first.end(), last.begin(), last.end());
    result += get(first).first;
  }
  cout << N * (long long)M - result * (long long)K << endl;
}
