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 T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
const long double eps = 1e-10L;
long long a[1000006];
vector<pair<long long, long long> > v, temp;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  long long ans = n * m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long p = a[1];
  long long cnt = 1;
  for (long long i = 2; i <= n; i++) {
    if (a[i] == p)
      cnt++;
    else {
      v.push_back(make_pair(p, cnt));
      p = a[i];
      cnt = 1;
    }
  }
  v.push_back(make_pair(p, cnt));
  for (long long i = 0; i < v.size(); i++) {
    ans -= (v[i].second / k) * m;
    v[i].second %= k;
  }
  for (long long i = 0; i < v.size(); i++) {
    if (v[i].second > 0) temp.push_back(v[i]);
  }
  long long sz = (long long)temp.size();
  long long rem;
  for (long long i = 0; i < sz - 1 - i; i++) {
    long long j = sz - 1 - i;
    if (temp[i].first != temp[j].first) {
      cout << ans;
      return 0;
    }
    long long z = temp[i].second + temp[j].second;
    if (z < k) {
      cout << ans;
      return 0;
    }
    ans -= (m - 1) * k;
    if (z > k) {
      cout << ans;
      return 0;
    }
  }
  long long w = temp[sz / 2].second * m;
  ans -= (w / k) * k;
  if (w % k != 0) {
    cout << ans;
    return 0;
  }
  cout << 0;
}
