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, k, m;
vector<pair<long long, long long>> ar;
long long solve() {
  long long nn = 0;
  for (int i = 0; i < ar.size(); i++) nn += ar[i].first;
  if (k > ar.size()) {
    if (ar.size() == 1) {
      return (ar[0].first * m) % k;
    } else {
      return (n * m);
    }
  }
  int l = 0, r = ar.size() - 1;
  long long t;
  while (l < r && ar[l].second == ar[r].second) {
    if ((ar[l].first + ar[r].first) % k == 0) {
      l++;
      r--;
    } else {
      t = (ar[l].first + ar[r].first) % k;
      l++;
      r--;
      break;
    }
  }
  if (t > 0 || l != r) {
    long long s = t;
    for (int i = l; i <= r; i++) {
      s += ar[i].first;
    }
    return (nn - s) + s * m;
  }
  return (ar[l].first * m) % k;
}
int main() {
  cin >> n >> k >> m;
  int t;
  cin >> t;
  pair<int, int> p = make_pair(1, t);
  for (int i = 1; i < n; i++) {
    cin >> t;
    if (p.second == t) {
      p.first = (p.first + 1) % k;
    } else {
      if (p.first) {
        ar.push_back(p);
      }
      p = make_pair(1, t);
    }
  }
  if (p.first) {
    ar.push_back(p);
  }
  cout << solve() << endl;
  return 0;
}
