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 LIM = 600010;
;
const int TRIM = 300000;
pair<vector<pair<int, int64_t>>, int64_t> getAnswer(const vector<int>& a, int m,
                                                    int k) {
  if (m == 0) {
    return {{}, 0};
  } else {
    vector<pair<int, int64_t>> stk;
    pair<vector<pair<int, int64_t>>, int64_t> b = getAnswer(a, m / 2, k);
    int64_t rem = b.second * 2;
    for (int u = 0; u < 2; ++u) {
      for (const pair<int, int64_t>& p : b.first) {
        if (p.first >= 0 && !stk.empty() && p.first == stk.back().first) {
          stk.back().second += p.second;
        } else {
          stk.push_back(p);
        }
        while (!stk.empty()) {
          int64_t buckets = stk.back().second / k;
          if (buckets == 0) {
            break;
          }
          stk.back().second %= k;
          rem += buckets * k;
          if (stk.back().second == 0) {
            stk.pop_back();
          }
        }
      }
    }
    if (m & 1) {
      for (int x : a) {
        pair<int, int64_t> p = make_pair(x, (int64_t)1);
        if (p.first >= 0 && !stk.empty() && p.first == stk.back().first) {
          stk.back().second += p.second;
        } else {
          stk.push_back(p);
        }
        while (!stk.empty()) {
          int64_t buckets = stk.back().second / k;
          if (buckets == 0) {
            break;
          }
          stk.back().second %= k;
          rem += buckets * k;
          if (stk.back().second == 0) {
            stk.pop_back();
          }
        }
      }
    }
    if (((int)(stk).size()) > LIM) {
      vector<pair<int, int64_t>> nStk;
      for (int i = 0; i < TRIM; ++i) {
        nStk.push_back(stk[i]);
      }
      nStk.push_back(make_pair(-1, (int64_t)1));
      for (int i = ((int)(stk).size()) - TRIM; i < ((int)(stk).size()); ++i) {
        nStk.push_back(stk[i]);
      }
      stk = move(nStk);
    }
    return make_pair(stk, rem);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  vector<pair<int, int64_t>> rem;
  int64_t ans;
  tie(rem, ans) = getAnswer(a, m, k);
  cout << (int64_t)m * n - ans << '\n';
}
