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>
#pragma comment(linker, "/STACK:336777216")
using namespace std;
const int MAXN = 200000 + 10;
int N, K, M;
int A[MAXN], p[MAXN];
vector<int> r[MAXN];
void Work() {
  scanf("%d%d%d", &N, &K, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    p[i] = A[i];
  }
  sort(p, p + N);
  int n = unique(p, p + N) - p;
  if (n == 1) {
    long long Ans = (long long)N * (long long)M % (long long)K;
    printf("%I64d\n", Ans);
    return;
  }
  if (K >= N) {
    long long Ans = (long long)N * (long long)M;
    printf("%I64d\n", Ans);
    return;
  }
  for (int i = 0; i < N; i++) {
    A[i] = (lower_bound(p, p + n, A[i]) - p);
  }
  int ns = 0;
  long long pia = 0;
  vector<pair<int, int> > v;
  for (int i = 0; i < N; i++) {
    int a = A[i % N];
    if (ns == 0 || v[ns - 1].first != a) {
      v.emplace_back(a, 1);
      ns++;
    } else {
      v[ns - 1].second++;
      if (v[ns - 1].second == K) {
        v.pop_back();
        pia += (long long)K;
        ns--;
      }
    }
  }
  if (M == 1) {
    long long Ans = (long long)N * (long long)M - pia;
    printf("%I64d\n", Ans);
    return;
  }
  int NN = 0;
  for (auto pp : v) {
    for (int kk = 0; kk < pp.second; kk++) A[NN++] = pp.first;
  }
  N = NN;
  long long ppia = 0;
  int p1 = N - 1, p2 = 0;
  while (1) {
    if (A[p1] != A[p2]) break;
    int cur = 2;
    while (p1 - 1 >= 0 && A[p1] == A[p1 - 1]) {
      p1--;
      cur++;
    }
    while (p2 + 1 < N && A[p2] == A[p2 + 1]) {
      p2++;
      cur++;
    }
    p1--;
    p2++;
    ppia += cur / K * K;
    if (cur % K != 0) break;
    if (p1 == -1) {
      printf("0\n");
      return;
    }
  }
  if (p1 > p2) {
    long long Ans = (long long)N * (long long)M - ppia * (long long)(M - 1);
    printf("%I64d\n", Ans);
  } else {
    long long singl = (long long)(p2 - p1 - 1) * (long long)M % (long long)K;
    if (singl != 0) {
      long long Ans = (p1 + 1LL) + (long long)(N - p2) + singl;
      printf("%I64d\n", Ans);
    } else {
      ns = 0;
      v.clear();
      long long pia = 0;
      for (int i = 0; i <= p1; i++) {
        int a = A[i];
        if (ns == 0 || v[ns - 1].first != a) {
          v.emplace_back(a, 1);
          ns++;
        } else {
          v[ns - 1].second++;
          if (v[ns - 1].second == K) {
            v.pop_back();
            pia += (long long)K;
            ns--;
          }
        }
      }
      for (int i = p2; i < N; i++) {
        int a = A[i];
        if (ns == 0 || v[ns - 1].first != a) {
          v.emplace_back(a, 1);
          ns++;
        } else {
          v[ns - 1].second++;
          if (v[ns - 1].second == K) {
            v.pop_back();
            pia += (long long)K;
            ns--;
          }
        }
      }
      long long Ans = (p1 + 1LL) + (long long)(N - p2) - pia;
      printf("%I64d\n", Ans);
    }
  }
}
int main() {
  Work();
  return 0;
}
