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 = (int)1e5 + 5;
int n, k;
long long rep;
int val[N], cnt[N], len = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> rep;
  for (int i = 1; i <= n; i++) {
    int foo;
    cin >> foo;
    if (len == 0 || foo != val[len]) {
      len++;
      val[len] = foo;
      cnt[len] = 1;
    } else {
      cnt[len]++;
    }
    if (cnt[len] == k) len--;
  }
  n = len;
  if (n == 0) {
    cout << "0\n";
    return 0;
  }
  int st = 1;
  int dr = n;
  while (st < dr && val[st] == val[dr] && cnt[st] + cnt[dr] == k) {
    st++;
    dr--;
  }
  if (st < dr && val[st] == val[dr] && cnt[st] + cnt[dr] > k) {
    cnt[dr] = (cnt[st] + cnt[dr]) % k;
    cnt[st] = 0;
  }
  if (st > dr) {
    cout << "0\n";
    return 0;
  }
  if (st == dr) {
    long long total = cnt[st] * rep;
    total %= k;
    cout << total << "\n";
    return 0;
  }
  long long total = 0;
  for (int i = st; i <= dr; i++) total += cnt[i];
  total *= rep;
  total += st - 1;
  total += st - 1;
  cout << total << "\n";
  return 0;
}
