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 Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  int n, k, m, a;
  scanf("%d", &n), scanf("%d", &k), scanf("%d", &m);
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back({a, 1});
  }
  while (v.size() > 1 and v[v.size() - 1].first == v[v.size() - 2].first) {
    v[v.size() - 2].second += v[v.size() - 1].second;
    v.pop_back();
  }
  int l = 0, r = v.size() - 1;
  long long int ans = 0;
  bool cont = true;
  while (l < r) {
    if (v[l].first != v[r].first) {
      cont = false;
      break;
    }
    int total = v[l].second + v[r].second;
    if (total == k) {
      ans += total;
      l++, r--;
    } else if (total > k) {
      ans += total + ((m - 1) * 1LL * total) % k;
      l++, r--;
      cont = false;
      break;
    } else {
      cont = false;
      break;
    }
  }
  if (cont and l == r) {
    if ((v[l].second * 1LL * m) % k == 0) {
      ans = 0;
    } else {
      ans += (v[l].second * 1LL * m) % k;
    }
  } else {
    for (int i = l; i <= r; i++) {
      ans += v[i].second * 1LL * m;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
