#include <bits/stdc++.h>
using namespace std;
using LL = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename S>
using P = pair<T, S>;
template <class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
using LD = long double;
template <typename T, typename S>
void check(T& a, S& b) {
  if (a >= b) {
    a %= b;
  }
}
template <typename T>
T gcd(T u, T v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
const int N = (int)1e5 + 10;
LL n, k, m;
LL a[N];
LL solve(LL st, LL en, LL sum, V<P<LL, LL>>& ans) {
  if (st == en) {
    return (ans[st].second * 1LL * m) % k;
  }
  if (ans[st].first != ans[en].first) {
    return (sum * 1LL * m);
  }
  if (en == st + 1) {
    return ((ans[st].first + ans[en].second) * 1LL * m) % k;
  }
  LL cnt = (ans[st].second + ans[en].second) % k;
  if (!cnt) {
    sum -= (ans[st].second + ans[en].second);
    auto t = solve(st + 1, en - 1, sum, ans);
    if (!t) return (ans[st].second + ans[en].second) % k;
    return ans[st].second + ans[en].second + t;
  } else {
    cerr << (m - 1) * 1LL * cnt << '\n';
    return (m - 1) * 1LL * cnt +
           m * 1LL * (sum - ans[st].second - ans[en].second) + ans[st].second +
           ans[en].second;
  }
}
void done(LL idx, V<P<LL, LL>>& ans) {
  if (idx == n) return;
  LL i = idx;
  LL cnt = 0;
  while (i < n && a[i] == a[idx]) i++, cnt++;
  cnt %= k;
  done(i, ans);
  if (!ans.empty() && ans.back().first == a[idx]) {
    cnt = (cnt + ans.back().second) % k;
    ans.pop_back();
  }
  if (cnt) ans.push_back({a[idx], cnt});
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  ;
  cin >> n >> k >> m;
  for (LL i = 0; i < (LL)n; i++) cin >> a[i];
  V<P<LL, LL>> ans;
  done(0, ans);
  reverse(ans.begin(), ans.end());
  n = (LL)ans.size();
  LL sum = 0;
  for (auto& i : ans) sum += i.second;
  cout << solve(0, n - 1, sum, ans) << '\n';
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
