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>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1123456;
const long long MOD = 1123456769;
using namespace std;
int b[MAXN], a[MAXN], n, k, kol_l[MAXN], kol_r[MAXN], prevv[MAXN];
long long check(int l, int r) {
  int res = r - l + 1;
  kol_r[r] = 1;
  prevv[r] = r - 1;
  for (int i = r - 1; i >= 1; i--) {
    if (b[i] == b[i + 1])
      kol_r[i] = kol_r[i + 1] + 1;
    else
      kol_r[i] = 1;
    prevv[i] = i - 1;
  }
  kol_l[l - 1] = 0;
  for (int i = l; i <= r; i++) {
    if (b[i] == b[prevv[i]])
      kol_l[i] = kol_l[prevv[i]] + 1;
    else
      kol_l[i] = 1;
    if (kol_l[i] == k) {
      prevv[i + 1] = prevv[i - k + 1];
      kol_l[i] = 0;
      res -= k;
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(time(0));
  long long m, i, j, ans, l, r, R, L, K, N = 0;
  cin >> n >> k >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (j = 1; j <= min(4LL, m); j++)
    for (i = 1; i <= n; i++) b[i + j * n - n] = a[i];
  ans = check(1, n * min(m, 4LL));
  int res = r - l + 1;
  l = 1;
  r = n;
  kol_r[r] = 1;
  prevv[r] = r - 1;
  prevv[r + 1] = r;
  for (int i = r - 1; i >= 1; i--) {
    if (b[i] == b[i + 1])
      kol_r[i] = kol_r[i + 1] + 1;
    else
      kol_r[i] = 1;
    prevv[i] = i - 1;
  }
  kol_l[l - 1] = 0;
  for (int i = l; i <= r; i++) {
    if (b[i] == b[prevv[i]])
      kol_l[i] = kol_l[prevv[i]] + 1;
    else
      kol_l[i] = 1;
    if (kol_l[i] == k) {
      prevv[i + 1] = prevv[i - k + 1];
      kol_l[i] = 0;
      res -= k;
    }
  }
  vector<int> v;
  int now = prevv[r + 1];
  while (now >= l) {
    v.push_back(now);
    now = prevv[now];
  }
  reverse(v.begin(), v.end());
  for (i = 0; i < v.size(); i++) a[++N] = b[v[i]];
  n = N;
  m -= 4;
  if (m > 0) {
    L = 1;
    R = n;
    while (a[L] == a[R]) {
      r = R - 1;
      l = L + 1;
      while (r >= L)
        if (a[r] == a[r - 1])
          --r;
        else
          break;
      while (R >= l)
        if (a[l] == a[l + 1])
          ++l;
        else
          break;
      if (l > r) {
        K = R - L + 1;
        m += 4;
        ans -= (K * 4) % k;
        K *= m;
        ans += K % k;
        cout << ans << "\n";
        return 0;
      }
      if (l - L >= R - r) {
        K = l - L + R - r;
        K %= k;
        R = r;
        L = l - K;
      } else {
        K = l - L + R - r;
        K %= k;
        L = l;
        R = r + K;
      }
    }
    ans += check(L, R) * m;
  }
  cout << ans << "\n";
  return 0;
}
