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;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937_64 rng(61378913);
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, k, q, l, r, x, y, z;
const long long template_array_size = 1e6 + 8432;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
void solve(int tc = 0) {
  cin >> n >> k >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<pair<long long, long long>> groups;
  long long ans = n * m;
  a[n] = -1;
  long long pt = 0;
  for (long long i = 0; i <= n; i++) {
    if (a[i] != a[pt]) {
      long long sz = i - pt, v = a[pt];
      pt = i;
      while (sz >= k) {
        sz -= k;
        ans -= m * k;
      }
      if (sz > 0) groups.push_back(make_pair(v, sz));
    }
  }
  long long lp = 0, rp = groups.size() - 1, tot = 0;
  while (lp < rp) {
    long long v = groups[lp].second + groups[rp].second;
    if (groups[lp].first == groups[rp].first) {
      tot += k * (v / k);
      if (v % k == 0) {
        ++lp;
        --rp;
      } else
        break;
    } else
      break;
  }
  if (lp < rp)
    ans -= tot * (m - 1);
  else if (lp > rp)
    ans = 0;
  else {
    long long v = groups[lp].second * m;
    ans = 0;
    if (v % k != 0) {
      ans += v - k * (v / k);
      for (long long i = 0; i < lp; i++) ans += groups[i].second;
      for (long long i = rp + 1; i < groups.size(); i++)
        ans += groups[i].second;
    }
  }
  cout << ans << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  { cin.tie(NULL); }
  cout << setprecision(12) << fixed;
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}
