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 m, n, k;
long long result;
int a[500002], b[500002];
vector<int> temp;
int pre[500002], suf[500002];
int suf1[500002];
void setup() {
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  result = 1LL * m * n;
}
void shortenArray(int *x, int &l, int numDup) {
  int num = 0, key = 0;
  for (int i = 1; i <= l; ++i) {
    temp.push_back(x[i]);
    if (x[i] == key)
      num++;
    else {
      key = x[i];
      num = 1;
    }
    if (num == k) {
      result -= 1LL * k * numDup;
      while (num--) {
        temp.pop_back();
      }
    }
  }
  l = (int)temp.size();
  for (int i = 1; i <= l; ++i) {
    x[i] = temp[i - 1];
  }
  temp.clear();
}
void preprocess() {
  shortenArray(a, n, m);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1])
      pre[i] = pre[i - 1];
    else
      pre[i] = i;
  }
  for (int i = n; i >= 1; --i) {
    if (a[i] == a[i + 1])
      suf[i] = suf[i - 1];
    else
      suf[i] = i;
  }
}
void process() {
  int i = 1, j = n;
  int key;
  int num = 0;
  while (suf[i] < j) {
    int ip = i, jp = j;
    key = a[j];
    num = 0;
    while (a[j] == key && num < k) {
      j--;
      num++;
    }
    if (num < k) {
      while (a[i] == key && num < k) {
        i++;
        num++;
      }
    }
    if (num == k)
      result -= 1LL * k * (m - 1);
    else {
      i = ip;
      j = jp;
      break;
    }
  }
  if (suf[i] >= j) {
    result -= 1LL * m * (j - i + 1) / k * k;
    if (m * (j - i + 1) % k == 0) {
      for (int t = 1; t <= i - 1; ++t) b[t] = a[t];
      for (int t = j + 1; t <= n; ++t) b[t + i - j - 1] = a[t];
      int l = i - 1 + n - j;
      shortenArray(b, l, 1);
    }
  }
  printf("%I64d\n", result);
}
int main() {
  setup();
  preprocess();
  process();
  return 0;
}
