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>
long long arr[100010];
long long count[100010];
long long n, k, m;
long long get_ans(long long st, long long ed, long long rep) {
  if (ed - st + 1 == 0) return 0;
  if (st == ed) return rep % k;
  if (ed - st + 1 <= k) {
    int i;
    for (i = st; i < ed; ++i)
      if (arr[i] != arr[i + 1]) break;
    if (i < ed)
      return rep * (ed - st + 1);
    else
      return (rep * (ed - st + 1)) % k;
  }
  if (arr[st] != arr[ed]) return rep * (ed - st + 1);
  long long cnt = 2, ss = st, ee = ed;
  while (st <= ed && cnt < k) {
    if (arr[st + 1] == arr[ed]) {
      ++st;
      ++cnt;
      continue;
    } else if (arr[st] == arr[ed - 1]) {
      --ed;
      ++cnt;
      continue;
    } else
      break;
  }
  if (cnt < k) return rep * (ee - ss + 1);
  long long X = get_ans(st + 1, ed - 1, rep);
  if (X == 0)
    return 0;
  else
    return X + k;
}
int main() {
  long long i, cnt;
  scanf("%lld%lld%lld", &n, &k, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%lld", &arr[i]);
    if (i == 1) {
      count[i] = 1;
      continue;
    }
    if (arr[i] == arr[i - 1]) {
      count[i] = count[i - 1] + 1;
      if (count[i] == k) {
        i -= k;
        n -= k;
        continue;
      }
    } else
      count[i] = 1;
  }
  printf("%lld", get_ans(1, n, m));
}
