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, a[100005], length(), b[100005], t, s;
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int cons = 1;
  t = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1])
      cons++;
    else
      cons = 1;
    t++;
    if (cons == k) {
      t -= (k - 1);
    }
    b[t] = a[i];
  }
  int l = 1, r = t, p = 0;
  while (l <= r) {
    int lt = l, rt = r;
    if (l == r) {
      p = 1;
      s = 1;
      break;
    }
    if (b[l] != b[r]) {
      p = 1;
      for (int i = l; i <= r; i++) {
        if (b[i] != b[l]) p = 0;
      }
      s = r - l + 1;
      break;
    }
    while (l < r && b[l + 1] == b[r]) l++;
    while (l < r && b[r - 1] == b[l]) r--;
    long long cnt = (l - lt + 1) + (rt - r + 1);
    if (cnt % k) {
      if (l == r) p = 1;
      s = r - l - 1 + cnt % k;
      break;
    }
    l++;
    r--;
  }
  long long ded = s * m;
  if (p) ded %= k;
  if (ded)
    cout << ded + t - s;
  else
    cout << 0;
}
