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;
long long n, k, m;
int a[100000];
int cur = -1;
vector<pair<long long, long long> > go, go2;
long long ans;
int main() {
  cin >> n >> k >> m;
  ans = (long long)n * m;
  go.push_back(make_pair(0, 0));
  for (int i = 0; i < n; i++) {
    cin >> 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));
  }
  int p;
  bool was = true;
  int r = go.size() - 1;
  for (int i = 1; i <= r; i++) {
    int back = r - i + 1;
    if (go[i].first == go[back].first && go[i].second + go[back].second == k) {
      ans -= k * (m - 1);
    } else {
      if (i == r / 2 + r % 2 && r % 2)
        ;
      else {
        if (go[i].first == go[back].first &&
            go[i].second + go[back].second > k) {
          ans -= k * (m - 1);
          go[i].second -= k;
        }
      }
      p = i - 1;
      was = false;
      break;
    }
  }
  if (was) p = r;
  if (p >= r / 2 + r % 2) p = r;
  if (p == r) {
    if (m % 2) {
      int ans = 0;
      for (int i = 0; i < go.size(); i++) ans += go[i].second;
      cout << ans;
    } else
      cout << 0;
    return 0;
  }
  if (r % 2 && p == r / 2) {
    if ((go[p + 1].second * m) % k == 0) {
      cout << 0;
      return 0;
    } else {
      ans -= ((go[p + 1].second * m) / k) * k;
      cout << ans;
      return 0;
    }
  }
  cout << ans;
}
