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 MAXN = 1e5 + 5;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
template <class T>
inline bool read(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
pair<int, int> p[MAXN];
int main() {
  int n, k, m, cnt = 0;
  cin >> n >> k >> m;
  int nn = n;
  for (int i = 1; i <= nn; ++i) {
    int x;
    scanf("%d", &x);
    if (cnt == 0 || x != p[cnt].first)
      p[++cnt] = make_pair(x, 1);
    else {
      p[cnt].second++;
      if (p[cnt].second == k) {
        cnt--;
        n -= k;
      }
    }
  }
  int l = 1, r = cnt, d = 0;
  while (l < r) {
    if (p[l].first == p[r].first) {
      int tmp = p[l].second + p[r].second;
      if (tmp / k * k == tmp) {
        d += tmp;
        l++;
        r--;
      } else {
        d += tmp / k * k;
        break;
      }
    } else
      break;
  }
  long long ans;
  if (l == r) {
    ans = (long long)p[l].second * m % k;
    if (ans) ans += d;
  } else
    ans = (long long)(n - d) * m + d;
  printf("%I64d", ans);
  return 0;
}
