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;
long long n;
long long m, k;
vector<int> pendek(vector<int> &t) {
  int temp;
  vector<int> v, pref;
  for (temp = 0; temp < t.size(); temp++) {
    int x = t[temp];
    v.push_back(x);
    if (v.back() == v[v.size() - 2])
      pref.push_back(pref.back() + 1);
    else
      pref.push_back(1);
    if (pref.back() == k) {
      int cnt = k;
      while (cnt--) {
        v.pop_back();
        pref.pop_back();
      }
    }
  }
  return v;
}
int main() {
  cin >> n >> k >> m;
  vector<int> v, pref;
  int temp;
  for (temp = 0; temp < n; temp++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  vector<int> tempo = pendek(v);
  long long pen = (long long)(n - tempo.size()) * m;
  if (v.size() == 0) {
    cout << 0 << "\n";
    return 0;
  }
  int left = 0, right = v.size() - 1, cnt = 2, laf = -1, lar = v.size();
  while (left < right) {
    if (v[left] != v[right]) break;
    if (cnt == k) {
      laf = left;
      lar = right;
      left++;
      right--;
      cnt = 2;
      pen += (m - 1) * k;
    } else if (v[left] == v[left + 1]) {
      left++;
      cnt++;
      if (cnt == k) {
        laf = left;
        lar = right;
        left++;
        right--;
        cnt = 2;
        pen += (m - 1) * k;
      }
    } else if (v[right] == v[right - 1]) {
      right--;
      cnt++;
      if (cnt == k) {
        laf = left;
        lar = right;
        right--;
        left++;
        cnt = 2;
        pen += (m - 1) * k;
      }
    } else
      break;
  }
  if (left == right) {
    cnt--;
    cnt = cnt * m;
    pen += cnt / k * k;
    if (cnt % k == 0) {
      vector<int> pref;
      for (temp = 0; temp <= laf; temp++) pref.push_back(v[temp]);
      for (temp = lar; temp < v.size(); temp++) pref.push_back(v[temp]);
      vector<int> tot = pendek(pref);
      pen += pref.size() - tot.size();
    }
  }
  cout << n * m - pen << "\n";
}
