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 N = 2e5 + 6;
const long long MOD2 = 998244353;
const long long MOD = 1e9 + 7;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long k, n, m;
  cin >> n >> k >> m;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  vector<pair<int, int> > v;
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (!v.empty() && v.back().first == a[i]) {
      v.back().second++;
    } else
      v.push_back({a[i], 1});
    if (v.back().second == k) {
      v.pop_back();
      ans -= m * k;
    }
  }
  int i = 0, j = v.size() - 1;
  long long pat = 0;
  bool fl = false;
  while (j > i) {
    if (v[i].first == v[j].first && v[i].second + v[j].second == k) {
      i++;
      j--;
      pat += k;
      continue;
    }
    if (v[i].first == v[j].first && v[i].second + v[j].second > k) {
      pat += k;
    }
    fl = true;
    break;
  }
  if (fl) {
    cout << ans + n * m - (m - 1) * pat << endl;
    return 0;
  }
  if (i == j) {
    if (((long long)v[i].second * m) % k == 0)
      cout << 0 << endl;
    else {
      cout << ans + n * m - (m - 1) * pat - (long long)v[i].second * m +
                  (long long)v[i].second * m % k
           << endl;
    }
    return 0;
  }
  if (m % 2) {
    cout << pat << endl;
  } else
    cout << 0 << endl;
  return 0;
}
