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;
int a[4 * 100005];
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i + n + 1] = a[i];
  }
  int mid = n, sum = 0;
  for (int i = n - 1, j = n + 1; i >= 0; i--, j++) {
    if (a[i] == a[j]) {
      sum++;
    } else
      break;
  }
  if (n == 1) {
    printf("%d\n", m - k);
  }
  int temp, ans = sum * 2;
  if (ans % k == 0) {
    temp = (n - sum) * (m - 1);
  } else {
    ans = ans - (ans % k);
    ans /= 2;
    temp = (n - ans) * (m - 1);
  }
  cout << temp << endl;
}
