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;
int n, k, m;
int a[MAXN];
long long res;
void solve(deque<int> &a) {
  if (a.empty()) return;
  int l = 0;
  int r = (int)a.size() - 1;
  while (l < (int)a.size() && a[l] == a[0]) {
    ++l;
  }
  while (r > -1 && a[r] == a.back()) {
    --r;
  }
  if (l == (int)a.size()) {
    res -= l * 1ll * m / k * k;
    if (l * 1ll * m % k == 0) {
      a.clear();
    }
    return;
  }
  int pref = l;
  int suff = (int)a.size() - 1 - r;
  if (a[0] == a.back() && pref + suff == k) {
    res -= (m - 1) * 1ll * k;
    while (pref-- > 0) {
      a.pop_front();
    }
    while (suff-- > 0) {
      a.pop_back();
    }
    solve(a);
    if (a.empty()) res -= k;
  } else if (a[0] == a.back() && pref + suff > k) {
    res -= (m - 1) * 1ll * k;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> m;
  res = n * 1ll * m;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    a[i] = x;
  }
  vector<pair<int, int> > st;
  for (int i = 0; i < n; ++i) {
    if (!st.empty()) {
      if (st.back().first == a[i]) {
        ++st.back().second;
        if (st.back().second == k) {
          res -= k * 1ll * m;
          st.pop_back();
        }
      } else {
        st.push_back({a[i], 1});
      }
    } else {
      st.push_back({a[i], 1});
    }
  }
  deque<int> b;
  for (int i = 0; i < (int)st.size(); ++i) {
    for (int j = 0; j < (int)st[i].second; ++j) {
      b.push_back(st[i].first);
    }
  }
  solve(b);
  cout << res << endl;
  return 0;
}
