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 a[100000];
int cur = -1;
deque<pair<int, int> > go, go2;
long long ans;
int main() {
  scanf("%d %d %d", &n, &k, &m);
  ans = (long long)n * m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (go.size() && go.back().first == a[i]) {
      int curCnt = go.back().second;
      go.pop_back();
      curCnt++;
      if (curCnt == k)
        ans -= (long long)k * m;
      else
        go.push_back(make_pair(a[i], curCnt));
    } else
      go.push_back(make_pair(a[i], 1));
  }
  for (int i = 0; i < go.size(); i++)
    cout << go[i].first << " " << go[i].second << endl;
  for (int i = 0; i < go.size(); i++) go2.push_back(go[i]);
  int curIdx1 = 0;
  int curIdx2 = go.size() - 1;
  while (curIdx1 != curIdx2 && go.size() > 1 &&
         go.back().first == go2.front().first &&
         go.back().second + go2.front().second == k) {
    ans -= (long long)k * (m - 1);
    go.pop_back();
    curIdx1++;
    go2.pop_front();
    curIdx2--;
  }
  if (curIdx1 != curIdx2 && go.size() &&
      go.back().second + go2.front().second > k &&
      go.back().first == go2.front().first) {
    ans -= (long long)k * (m - 1);
    cout << ans;
    return 0;
  }
  if (curIdx1 == curIdx2) {
    ans -= ((long long)m * go.back().second) / k * k;
    if (!(((long long)m * go.back().second) % k)) {
      curIdx1++;
      curIdx2--;
      go.pop_back();
      go2.pop_front();
    }
  }
  while (go.size() && go.back().first == go2.front().first &&
         go.back().second + go2.front().second == k) {
    ans -= (long long)k;
    go.pop_back();
    curIdx1++;
    go2.pop_front();
    curIdx2--;
  }
  if (go.size() && go.back().second + go2.front().second > k &&
      go.back().first == go2.front().first)
    ans -= (long long)k;
  cout << ans;
}
