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 = 100007;
int v[N];
int n, k, m;
long long step1(vector<pair<int, int> > vec) {
  int tot = 0;
  stack<pair<int, int> > st;
  st.push(pair<int, int>(-1, 0));
  for (int i = 0; i < vec.size(); ++i) {
    pair<int, int> item = vec[i];
    pair<int, int> aux = st.top();
    if (item.first == aux.first) {
      st.pop();
      tot += (item.second + aux.second) - (item.second + aux.second) % k;
      if ((item.second + aux.second) % k)
        st.push(pair<int, int>(item.first, (item.second + aux.second) % k));
    } else
      st.push(item);
  }
  return tot;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> m;
  for (int i = 0; i < n; ++i) cin >> v[i];
  vector<pair<int, int> > vec;
  for (int l = 0, r; l < n; l = r) {
    r = l;
    while (r < n and v[r] == v[l]) ++r;
    vec.push_back(pair<int, int>(v[l], r - l));
  }
  long long tot = 0;
  tot += step1(vec) * m;
  int l = 0, r = vec.size() - 1;
  long long sum = 0;
  while (l < r) {
    if (vec[l].first != vec[r].first) break;
    long long aux = vec[l].second + vec[r].second;
    sum += aux - aux % k;
    aux %= k;
    if (aux) break;
    l++;
    r--;
  }
  tot += sum * (m - 1);
  if (l == r) {
    int j = l;
    pair<int, int> aux = vec[l];
    l--;
    r++;
    long long much = long long(aux.second) * m;
    tot += much - much % k;
    much %= k;
    vector<pair<int, int> > novo;
    for (int i = 0; i < j; ++i) {
      novo.push_back(vec[i]);
    }
    if (much) novo.push_back(pair<int, int>(aux.first, much));
    for (int i = vec.size() - 1; i > j; --i) {
      novo.push_back(vec[i]);
    }
    tot += step1(novo);
  }
  cout << long long(n) * long long(m) - tot << endl;
}
