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 mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;
int n, m, k;
long long merge(vector<int> &a, vector<int> &b, vector<int> &c) {
  long long temp = 0LL;
  vector<int> acc;
  for (int i = 0; i < (int)a.size() + (int)b.size(); i++) {
    int x;
    if (i < (int)a.size()) {
      x = a[i];
    } else {
      x = b[i - (int)a.size()];
    }
    if (c.size() > 0) {
      if (x == c.back()) {
        int pre = acc.back() + 1;
        if (pre == k) {
          int it = k - 1;
          while (it--) {
            c.pop_back();
            acc.pop_back();
          }
          temp++;
        } else {
          acc.push_back(pre);
          c.push_back(x);
        }
      } else {
        c.push_back(x);
        acc.push_back(1);
      }
    } else {
      c.push_back(x);
      acc.push_back(1);
    }
  }
  return temp;
}
int main() {
  cin >> n >> k >> m;
  long long tot = 1LL * n * m;
  long long ans = 0;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  vector<int> ul;
  vector<int> sa;
  long long re = merge(a, ul, sa);
  a = sa;
  ans += re * m;
  n = (int)a.size();
  if (n == 0) {
    cout << ans << endl;
    return 0;
  }
  vector<int> resi;
  do {
    bool flag = true;
    for (int i = 0; i < (int)a.size(); i++) {
      if (a[i] != a[0]) flag = false;
    }
    if (flag) {
      long long sz = 1LL * m * a.size();
      ans += sz / k;
      long long d = sz % (1LL * k);
      if (d > 0) {
        d = (1LL * k - d) % (1LL * d);
        bool temp = true;
        if (1LL * resi.size() < d) break;
        for (long long i = 0; i < d; i++) {
          if (resi[i] != a[0]) temp = false;
        }
        if (temp) ans++;
      }
      break;
    } else {
      if (k > (int)a.size()) {
        break;
      }
    }
    if (m % 2) {
      vector<int> c;
      long long re = merge(a, resi, c);
      resi = c;
      ans += re;
      if ((int)resi.size() > 2 * k) {
        int it = k;
        while (it--) {
          resi.pop_back();
        }
      }
    }
    m /= 2;
    if (m == 0LL) break;
    vector<int> c;
    long long re = merge(a, a, c);
    ans += re * m;
    a = c;
  } while (m > 0);
  cout << tot - ans * k << endl;
  return 0;
}
