#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void Print() { cout << endl; }
template <typename T1, typename... T>
void Print(const T1 &t1, const T &...t) {
  cout << t1 << " ";
  Print(t...);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class Iterator>
ostream &output_cantainer(ostream &os, Iterator first, Iterator last,
                          bool space = true) {
  if (space) {
    for (Iterator it = first; it != last; it++) {
      os << (*it) << ' ';
    }
    os << endl;
  } else
    for (Iterator it = first; it != last; it++) {
      os << (*it) << endl;
    }
  return os;
}
const int N = 1e5 + 4;
int n, k, m, a[N], on;
LL ans;
vector<pair<int, int> > que, que2;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  on = n;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    if (!que.empty() && a[i] == que.back().first) {
      if (++que.back().second == k) {
        ans += 1ll * k * m;
        que.pop_back();
      }
    } else
      que.emplace_back(a[i], 1);
  }
  n = que.size();
  int l = 0, r = n - 1;
  while (l < r) {
    if (que[l].first != que[r].first) break;
    int tot = que[l].second + que[r].second;
    ans += 1ll * (m - 1) * (tot / k * k);
    if (tot % k != 0) break;
    l++;
    r--;
  }
  if (l == r) {
    LL tot = 1ll * que[l].second * m;
    ans += tot / k * k;
    if (tot % k == 0) {
      for (int i = 0; i < l; i++) que2.push_back(que[i]);
      for (int i = l + 1; i < n; i++) {
        if (!que2.empty() && que[i].first == que2.back().first) {
          int t = que2.back().second + que[i].second;
          ans += t / k * k;
          que2.back().second = t % k;
          if (t % k == 0) que2.pop_back();
        } else
          que2.push_back(que[i]);
      }
    }
  } else if (l > r) {
    for (int i = 0; i < n; i++) {
      if (!que2.empty() && que[i].first == que2.back().first) {
        int t = que2.back().second + que[i].second;
        ans += t / k * k;
        que2.back().second = t % k;
        if (t % k == 0) que2.pop_back();
      } else
        que2.push_back(que[i]);
    }
  }
  printf("%lld\n", 1ll * m * on - ans);
}
