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;
vector<pair<int, int> > v;
int a[MAXN];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int flg = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (!flg) {
      flg++;
    } else if (a[i] == a[i - 1]) {
      flg++;
    } else {
      flg %= k;
      if (flg) {
        ans += flg;
        v.push_back(pair<int, int>(a[i - 1], flg));
      }
      flg = 1;
    }
  }
  flg %= k;
  int sz = v.size();
  if (flg) {
    ans += flg;
    v.push_back(pair<int, int>(a[n - 1], flg));
  }
  ans *= m;
  if (v.size() == 1) {
    cout << 1LL * n * m % k << endl;
  } else {
    int l = 0, r = v.size() - 1;
    while (1) {
      if (l == r) {
        int tmp = m * v[l].second % k;
        ans -= m * v[l].second - tmp;
        if (tmp == 0) {
          l--;
          while (l >= 0) {
            int s;
            if (v[l].first == v[sz - l - 1].first) {
              s = v[l].second + v[sz - l - 1].second;
              ans -= s - s % k;
              l--;
            } else
              break;
            if (s % k != 0) break;
          }
        }
        break;
      }
      if (v[l].first != v[r].first) break;
      int tmp = v[l].second + v[r].second;
      if (tmp != k) {
        ans -= tmp / k * k * (m - 1);
        break;
      } else {
        ans -= k * (m - 1);
        l++;
        r--;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
