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 maxn = 100000 + 5;
int n, k;
long long m;
int a[maxn], f[maxn], b[maxn];
int getf(int x) { return x == f[x] ? f[x] : f[x] = getf(f[x]); }
void merge(int u, int v) {
  int fu = getf(u), fv = getf(v);
  if (fu == fv)
    return;
  else
    f[fv] = fu;
}
vector<pair<pair<int, int>, int> > seg;
deque<int> deq;
int main() {
  scanf("%d%d%lld", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    deq.push_back(a[i]);
  }
  bool ALL = true;
  int tmp = a[1];
  for (int i = 2; i <= n; i++)
    if (tmp != a[i]) ALL = false;
  if (ALL) {
    printf("%lld\n", (long long)n * m - (long long)n * m / k * k);
    exit(0);
  }
  int l1 = 0, r1 = n + 1;
  tmp = -1;
  while (l1 + 1 <= r1 - 1 && a[l1 + 1] == a[r1 - 1] &&
         (tmp == -1 || tmp == a[l1 + 1]))
    tmp = a[l1 + 1], l1++, r1--;
  int len = l1 + n - r1 + 1, tou = l1, wei = n - r1 + 1;
  tou = l1 - (l1 / k) * k, wei = wei - (wei / k) * k;
  if (len >= k) {
    int tsum = (len / k) * k;
    while (tsum && deq.back() == tmp) deq.pop_back(), tsum--;
    while (tsum && deq.front() == tmp) deq.pop_front(), tsum--;
    int ptr = 0;
    while (!deq.empty()) a[++ptr] = deq.front(), deq.pop_front();
    n = ptr;
  }
  int l = 0, r = 0;
  bool upd = true;
  while (upd) {
    upd = false;
    l = 0, r = 0;
    tmp = 0;
    seg.clear();
    for (int i = 1; i <= n; i++) {
      if (!tmp)
        tmp = a[i], l = r = i;
      else {
        if (a[i] != tmp)
          seg.push_back(make_pair(make_pair(l, r), tmp)), tmp = -1;
        else
          r = i;
      }
    }
    if (tmp != -1) seg.push_back(make_pair(make_pair(l, r), tmp));
    for (int i = 1; i <= n + 1; i++) f[i] = i;
    for (int i = 0; i < (int)seg.size(); i++) {
      l = seg[i].first.first, r = seg[i].first.second, len = r - l + 1;
      if (len >= k) {
        upd = true;
        int RC = len / k * k, commfa = l + RC;
        for (int j = getf(l); j <= l + RC - 1; j = getf(j + 1)) f[j] = commfa;
      }
    }
    if (!upd) break;
    int ptr = 0;
    for (int i = getf(1); i <= n; i = getf(i + 1)) b[++ptr] = a[i];
    n = ptr;
    for (int i = 1; i <= n; i++) a[i] = b[i];
  }
  int delta = tou + wei;
  if (n == 1) n = 0, delta = delta - delta / k * k;
  printf("%lld\n", (long long)n * m + delta);
  return 0;
}
