#include <bits/stdc++.h>
using namespace std;
int N, K;
long long M;
int A[100004];
struct IdCount {
  int id, cnt;
};
const bool trace = false;
long long solve() {
  if (M <= 3) {
    vector<IdCount> B;
    for (int m = 0, _n = (M); m < _n; ++m) {
      for (int i = 0, _n = (N); i < _n; ++i) {
        if (B.empty() || A[i] != B.back().id)
          B.push_back({A[i], 1});
        else
          B.back().cnt = (B.back().cnt + 1) % K;
        if (B.back().cnt == 0) B.pop_back();
      }
    }
    long long res = 0;
    for (auto x : B) res += x.cnt;
    return res;
  }
  vector<IdCount> B;
  for (int i = 0, _n = (N); i < _n; ++i) {
    if (B.empty() || A[i] != B.back().id)
      B.push_back({A[i], 1});
    else
      B.back().cnt = (B.back().cnt + 1) % K;
    if (B.back().cnt == 0) B.pop_back();
  }
  if (trace) {
    for (auto x : B) fprintf(stderr, "(%d:%d) ", x.id, x.cnt);
    fprintf(stderr, "\n");
  }
  if (int((B).size()) == 0) return 0;
  if (int((B).size()) == 1) {
    return (B[0].cnt * M) % K;
  }
  if (int((B).size()) == 2) {
    long long res = 0;
    for (auto x : B) res += x.cnt;
    res *= M;
    return res;
  }
  long long res = 0;
  int L = 0, R = int((B).size()) - 1;
  for (; L < R; ++L, --R) {
    if (B[L].id != B[R].id) {
      long long sum_mid = 0;
      for (int i = (L), _b = (R); i <= _b; ++i) sum_mid += B[i].cnt;
      res += sum_mid * M;
      long long sum_ext = 0;
      for (int i = (0), _b = (L - 1); i <= _b; ++i) sum_ext += B[i].cnt;
      for (int i = (R + 1), _b = (int((B).size()) - 1); i <= _b; ++i)
        sum_ext += B[i].cnt;
      res += sum_ext;
      return res;
    }
    long long sum = (B[L].cnt + B[R].cnt) % K;
    if (sum != 0) {
      res += sum * (M - 1);
      long long sum_mid = 0;
      for (int i = (L + 1), _b = (R - 1); i <= _b; ++i) sum_mid += B[i].cnt;
      res += sum_mid * M;
      long long sum_ext = 0;
      for (int i = (0), _b = (L); i <= _b; ++i) sum_ext += B[i].cnt;
      for (int i = (R), _b = (int((B).size()) - 1); i <= _b; ++i)
        sum_ext += B[i].cnt;
      res += sum_ext;
      return res;
    }
  }
  if (trace) fprintf(stderr, "L: %d  R: %d\n", L, R);
  res = 0;
  if (L == R) {
    long long sum = (B[L].cnt * M) % K;
    if (sum != 0) {
      res += sum;
      for (int i = (0), _b = (L - 1); i <= _b; ++i) res += B[i].cnt;
      for (int i = (R + 1), _b = (int((B).size()) - 1); i <= _b; ++i)
        res += B[i].cnt;
      return res;
    } else
      L++, R--;
  }
  for (; L < N && R >= 0; ++L, --R) {
    if (B[R].id != B[L].id) {
      long long sum_ext = 0;
      for (int i = (0), _b = (R); i <= _b; ++i) sum_ext += B[i].cnt;
      for (int i = (L), _b = (N - 1); i <= _b; ++i) sum_ext += B[i].cnt;
      return res;
    }
    long long sum = (B[R].cnt + B[L].cnt) % K;
    if (sum != 0) {
      res = sum;
      long long sum_ext = 0;
      for (int i = (0), _b = (R - 1); i <= _b; ++i) sum_ext += B[i].cnt;
      for (int i = (L + 1), _b = (N - 1); i <= _b; ++i) sum_ext += B[i].cnt;
      return res;
    }
  }
  return res;
}
int main(int argc, char* argv[]) {
  scanf("%d %d %lld", &N, &K, &M);
  for (int i = 0, _n = (N); i < _n; ++i) scanf("%d", A + i);
  long long res = solve();
  printf("%lld\n", res);
  return 0;
}
