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 N = 1e5 + 87;
pair<int, int> a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, m, w = 0, c = 0;
  cin >> n >> k >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (!w || a[w - 1].first != x)
      a[w++] = {x, 1};
    else
      a[w - 1].second++;
    c += a[w - 1].second / k;
    if (!(a[w - 1].second %= k)) --w;
  }
  c *= m;
  if (m >= 2) {
    int l = 0, r = w - 1;
    for (; r - l + 1 >= 2; ++l, --r) {
      if (a[l].first != a[r].first) break;
      long long s = a[l].second + a[r].second;
      c += s / k * (m - 1);
      if (s % k) break;
    }
    if (r - l + 1 == 1) {
      long long s = a[l].second * m;
      c += s / k;
      if (s % k == 0) {
        while (--l >= 0 && ++r < w) {
          if (a[l].first != a[r].first) break;
          s = a[l].second + a[r].second;
          c += s / k;
          if (s % k) break;
        }
      }
    }
  }
  cout << n * m - c * k << endl;
}
