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 = 1e5 + 10;
vector<pair<int, int> > v;
int a[N];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int w = a[0];
  int count = 1;
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != w) {
      count %= k;
      v.push_back({w, count});
      sum += count;
      w = a[i];
      count = 1;
    }
  }
  sum += count;
  v.push_back({w, count});
  sum = sum * m;
  int len = v.size();
  int l = 0, r = len - 1;
  while (l < r) {
    if (v[l].first != v[r].first) break;
    if ((v[l].second + v[r].second) == k) {
      sum = sum - (long long)(m - 1) * k;
    }
    if (v[l].second + v[r].second > k) {
      sum = sum - (long long)(m + 1) * k;
      break;
    }
    l++, r--;
  }
  if (l > r) sum = 0;
  if (l == r) {
    if ((v[l].second + v[r].second) % k == 0) {
      sum -= v[0].second + v[len - 1].second;
    }
    sum -= (long long)v[l].second * m / k * k;
  }
  cout << sum << endl;
  return 0;
}
