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 long long maxn = 2e5 + 5;
long long n, m, x, y, z, k, cnt, ct;
long long a[maxn], b[maxn], c[maxn], cc[maxn];
int main() {
  cin >> n >> k >> m;
  for (register long long i = 1; i <= n; ++i) cin >> a[i];
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  ct = 1;
  for (register long long i = 2; i <= n + 1; ++i) {
    if (a[i] == a[i - 1])
      ct++;
    else {
      b[++cnt] = a[i - 1];
      c[cnt] = ct;
      ct = 1;
    }
  }
  if (cnt == 1) {
    cout << (n * m) % k << endl;
    return 0;
  }
  for (register long long i = 1; i <= cnt; ++i) cc[i] = cc[i - 1] + c[i];
  long long l = 1, r = cnt;
  while (b[l] == b[r]) {
    if (l != r) {
      if (c[l] + c[r] < k)
        break;
      else
        l++, r--;
    } else
      break;
  }
  if (l == r && k <= 2 * c[l]) {
    cout << (c[l] * m) % k;
    return 0;
  } else {
    cout << (m - 2) * (cc[r] - cc[l - 1]) + cc[r] + (cc[cnt] - cc[l - 1]);
  }
  return 0;
}
