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;
const int N = 100005;
int n, m, k;
long long res;
int a[N];
stack<int> st;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> m;
  res = 1LL * n * m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int L = 1, R = n;
  while (1) {
    if (a[L] != a[R]) break;
    int cnt = 0;
    int tmp = a[L];
    while (a[L] == tmp) L++, cnt++;
    while (a[R] == tmp) R--, cnt++;
    if (L > R) {
      cnt >>= 1;
      res -= 1LL * cnt * m / k * k;
      if (1LL * cnt * m % k == 0) {
        while (st.size()) {
          int tmp = st.top();
          st.pop();
          res -= tmp / k * k;
          if (tmp % k) break;
        }
      }
      break;
    } else {
      res -= 1LL * cnt / k * k * (m - 1);
      st.push(cnt);
      if (cnt % k) break;
    }
  }
  cout << res;
}
