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 MX = 100005;
long long n, k, m;
deque<pair<long long, long long> > a, x, y;
long long res;
void merge(deque<pair<long long, long long> > &d) {
  deque<pair<long long, long long> > r;
  while (d.size()) {
    if (r.empty() || r.back().first != d.front().first)
      r.emplace_back(d.front().first, 0);
    r.back().second += d.front().second;
    res += r.back().second / k;
    r.back().second %= k;
    if (!r.back().second) r.pop_back();
    d.pop_front();
  }
  swap(r, d);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    int in;
    cin >> in;
    a.emplace_back(in, 1);
  }
  merge(a);
  res *= m;
  if (m == 1) {
    cout << n * m - res * k << '\n';
    return 0;
  }
  if (a.size() == 1) {
    res += a.front().second * m / k;
    cout << n * m - res * k << '\n';
    return 0;
  }
  while (a.size() >= 2) {
    if (a.back().first != a.front().first) break;
    x.push_back(a.front());
    y.push_front(a.back());
    res += (a.back().second + a.front().second) / k * (m - 1);
    a.back().second += a.front().second;
    a.back().second %= k;
    a.pop_front();
    if (!a.back().second) a.pop_back();
  }
  if (a.size() == 1) {
    x.emplace_back(a[0].first, a[0].second * m);
    x.insert(x.end(), y.begin(), y.end());
    merge(x);
  }
  cout << n * m - res * k << '\n';
  return 0;
}
