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;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 5;
long long n, k, m;
int siz;
int a[maxn], b[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> m;
  long long res = n * m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (siz > 0 && a[siz - 1] == x) {
      b[siz - 1]++;
      if (b[siz - 1] == k) {
        res -= k * m;
        siz--;
      }
    } else {
      a[siz] = x;
      b[siz] = 1;
      siz++;
    }
  }
  if (siz <= 1) {
    res = res % k;
    out(res);
  }
  for (int i = 0; i < siz / 2; i++) {
    if (a[i] != a[siz - 1 - i]) {
      out(res);
    }
    long long count = b[i] + b[siz - 1 - i];
    if (count < k) {
      out(res);
    }
    res -= k * (m - 1);
    if (count > k) {
      out(res);
    }
  }
  assert(siz % 2 == 1);
  long long mid = b[siz / 2] * m;
  res -= mid / k * k;
  if (mid % k == 0) {
    res = 0;
  }
  out(res);
  return 0;
}
