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>
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
const int N = (int)1e5 + 228;
using namespace std;
int n, k, m, a[N];
long long ans;
void rec(int l, int r, int type) {
  if (r < l) return;
  if (a[l] == a[r] && !type) {
    int cnt1 = 0, cnt2 = 0;
    while (l + cnt1 <= r && a[l + cnt1] == a[l]) cnt1++;
    while (r - cnt2 >= l && a[r - cnt2] == a[r]) cnt2++;
    if (cnt1 == r - l + 1) {
      ans += 1ll * (1ll * m * cnt1) % k;
      return;
    }
    ans += (0ll + cnt1 + cnt2) % k * 1ll * m;
    if ((cnt1 + cnt2) % k) {
      ans += cnt1 % k;
      ans += cnt2 % k;
      rec(l + cnt1, r - cnt2, true);
    } else {
      long long cur = ans;
      rec(l + cnt1, r - cnt2, false);
      if (ans == cur)
        ans += (cnt1 + cnt2) % k;
      else
        ans += (cnt1 % k) + (cnt2 % k);
    }
    return;
  }
  if (!type) {
    int cntL = 0, cntR = 0;
    while (l + cntL <= r && a[l + cntL] == a[l]) cntL++;
    while (r - cntR >= l && a[r - cntR] == a[r]) cntR++;
    if (cntL % k > 0 || cntR % k > 0)
      type = true;
    else if (cntL % k == 0) {
      rec(l + cntL, r, false);
    } else {
      rec(l, r - cntR, false);
    }
  }
  if (type) {
    for (int i = l; i <= r; i++) {
      int cnt = 0;
      while (i + cnt <= r && a[i + cnt] == a[i]) cnt++;
      ans += 1ll * (cnt % k) * m;
      i += cnt - 1;
    }
    return;
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  rec(1, n, 0);
  cout << ans << endl;
  return 0;
}
