#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e6 + 6;
ll ans;
void gg() {
  cout << ans << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> k >> m;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  ans = 1LL * n * m;
  vector<pair<int, int>> s;
  if (*min_element((a).begin(), (a).end()) !=
      *max_element((a).begin(), (a).end())) {
    for (int i = 0; i < n; ++i) {
      int x = a[i];
      if (s.empty() || s.back().first != x) s.push_back({x, 0});
      if (s.back().first == x) ++s.back().second;
      if (s.back().second == k) {
        ans -= 1LL * k * m;
        s.pop_back();
      }
    }
    vector<int> aa;
    for (auto p : s)
      while (p.second--) aa.push_back(p.first);
    a = aa;
    n = a.size();
    s.clear();
    for (int i = 0; i < n; ++i) {
      int x = a[i];
      if (s.empty() || s.back().first != x) s.push_back({x, 0});
      if (s.back().first == x) ++s.back().second;
      if (s.back().second == k) s.pop_back();
    }
  } else {
    ans %= k;
    gg();
  }
  cerr << "ans = " << ans << endl;
  for (int x : a) cerr << x << ' ';
  cerr << endl;
  if (a.empty()) gg();
  auto t = s, e = s;
  for (int i = 0;;) {
    if (s.back().first == t[i].first) {
      if (i + 1 == t.size()) {
        ll l = s.back().second + t[i].second * 1LL * (m - 1);
        ans -= l - l % k;
        if (l % k == 0) {
          s.pop_back();
          ++i;
          a.clear();
          for (int j = 0; j < s.size(); ++j)
            while (s[j].second--) a.push_back(s[j].first);
          for (int j = i; j < e.size(); ++j)
            while (e[j].second--) a.push_back(e[j].first);
          s.clear();
          for (int i = 0; i < a.size(); ++i) {
            int x = a[i];
            if (s.empty() || s.back().first != x) s.push_back({x, 0});
            if (s.back().first == x) ++s.back().second;
            if (s.back().second == k) {
              ans -= k;
              s.pop_back();
            }
          }
        }
        gg();
      }
      int l = s.back().second + t[i].second;
      if (l % k == 0) {
        ans -= 1LL * (m - 1) * l;
        s.pop_back();
        t.pop_back();
        ++i;
        continue;
      } else {
        ans -= 1LL * (m - 1) * (l - l % k);
        gg();
      }
    } else
      break;
  }
  a.clear();
  for (auto p : s)
    while (p.second--) a.push_back(a[p.first]);
  for (int x : a) cerr << x << ' ';
  cerr << endl;
  gg();
  return 0;
}
