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 N = 1e5 + 7;
int n, k, m, a[N];
int gao(const vector<pair<int, int> > &x) {
  int ret = 0;
  for (int i = ((int)(x).size()) - 1, j = 0; i >= 0; --i, ++j) {
    if (x[i].first != x[j].first) break;
    if (x[i].second + x[j].second != k) break;
    ++ret;
  }
  return ret;
}
long long solve() {
  vector<pair<int, int> > v;
  for (int i = (0); i < (n); ++i)
    if (v.empty() || v.back().first != a[i]) {
      v.push_back({a[i], 1});
    } else {
      ++v.back().second;
      if (v.back().second == k) v.pop_back();
    }
  if (((int)(v).size()) == 0) return 0;
  long long ret = 0;
  for (int i = (0); i < (((int)(v).size())); ++i) ret += v[i].second;
  if (m == 1) return ret;
  if (((int)(v).size()) == 1) {
    ret = 1ll * v.back().second * m % k;
    return ret;
  }
  int p = gao(v);
  if (p < ((int)(v).size()) / 2) {
    ret = 1ll * ret * m - 1ll * p * k * (m - 1);
    int q = ((int)(v).size()) - p - 1;
    if (v[p].first == v[q].first && v[p].second + v[q].second >= k)
      ret -= 1ll * (m - 1) * k;
    return ret;
  } else if (p == ((int)(v).size())) {
    return (m & 1) * ret;
  } else {
    assert(p == (((int)(v).size()) / 2));
    int rm = 1ll * v[((int)(v).size()) >> 1].second * m % k;
    if (rm == 0) return 0;
    ret -= v[((int)(v).size()) >> 1].second;
    ret += rm;
    return ret;
  }
  return -1;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  cout << solve() << endl;
  return 0;
}
