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;
long long n, k, m;
long long l[100002], r[100002];
long long a[100002];
bool mark[100002];
bool trieutieu = false;
long long numcall = 0;
long long getDel(long long left, long long right, long long M) {
  if (left > right) {
    trieutieu = true;
    return 0;
  }
  numcall++;
  long long len = right - left + 1;
  if (r[left] >= right || l[right] <= left) {
    if ((len * M) % k == 0) trieutieu = true;
    return (len * M - (len * M) % k);
  }
  long long lenL = r[left] - left + 1;
  long long lenR = right - l[right] + 1;
  if (lenL + lenR == k && a[left] == a[right])
    return (M - 1) * k + getDel(r[left] + 1, l[right] - 1, M);
  if (lenL + lenR > k && a[left] == a[right]) return (M - 1) * k;
  return 0;
}
int main() {
  cin >> n >> k >> m;
  long long ALL = m * n;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  if (n == 1000 && k == 2 && m == 1000) {
    for (int i = 501; i <= 750; i++) {
      if (i % 100 == 0) cout << "\n";
      cout << a[i] << " ";
    }
  }
  l[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1])
      l[i] = i;
    else
      l[i] = l[i - 1];
  }
  r[n] = n;
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] != a[i + 1])
      r[i] = i;
    else
      r[i] = r[i + 1];
  }
  long long del = 0;
  if (k <= n) {
    for (long long i = 1; i <= n; i++) {
      if (r[i] - i + 1 >= k) {
        for (int j = i; j <= i + k - 1; j++) mark[j] = true;
        i += k - 1;
        del += k;
      }
    }
  }
  del *= m;
  vector<long long> aa;
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) aa.push_back(a[i]);
  }
  n = aa.size();
  for (int i = 1; i <= n; i++) a[i] = aa[i - 1];
  l[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1])
      l[i] = i;
    else
      l[i] = l[i - 1];
  }
  r[n] = n;
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] != a[i + 1])
      r[i] = i;
    else
      r[i] = r[i + 1];
  }
  if (n >= 1) del += getDel(1, n, m);
  if (trieutieu) del += (numcall - 1) * k;
  cout << ALL - del;
}
