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, m, k;
long long ans = 0;
int a[101010];
stack<pair<int, int> > cb;
void setup() {
  for (int i = 0; i < n; i++) {
    if (cb.empty() || a[i] != cb.top().first) {
      cb.push(make_pair(a[i], 1));
    } else {
      cb.top().second++;
      if (cb.top().second == k) {
        ans += m;
        cb.pop();
      }
    }
  }
  return;
}
void bruteForcesetup() {
  for (long long r = 0; r < m; r++) {
    for (int i = 0; i < n; i++) {
      if (cb.empty() || a[i] != cb.top().first) {
        cb.push(make_pair(a[i], 1));
      } else {
        cb.top().second++;
        if (cb.top().second == k) {
          ans++;
          cb.pop();
        }
      }
    }
  }
  return;
}
long long customSetup(stack<pair<int, int> > &res, vector<int> &b) {
  long long cnt = 0;
  for (int q : b) {
    if (res.empty() || res.top().first != q) {
      res.push(make_pair(q, 1));
    } else {
      res.top().second++;
      if (res.top().second == k) {
        res.pop();
        cnt++;
      }
    }
  }
  return cnt;
}
long long customSetup2(stack<pair<int, int> > &res, vector<int> &b, int r) {
  long long cnt = 0;
  while (r--) {
    for (int q : b) {
      if (res.empty() || res.top().first != q) {
        res.push(make_pair(q, 1));
      } else {
        res.top().second++;
        if (res.top().second == k) {
          res.pop();
          cnt++;
        }
      }
    }
  }
  return cnt;
}
vector<int> getStatus(stack<pair<int, int> > t) {
  vector<int> ret;
  while (!t.empty()) {
    pair<int, int> q = t.top();
    t.pop();
    for (int i = 0; i < q.second; i++) ret.push_back(q.first);
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
vector<int> getStatus2(stack<pair<int, int> > &t) {
  vector<int> ret;
  while (!t.empty()) {
    pair<int, int> q = t.top();
    t.pop();
    for (int i = 0; i < q.second; i++) ret.push_back(q.first);
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
stack<vector<int> > remain;
void go(vector<int> &lst, long long v) {
  if (lst.empty()) return;
  if (v % 2 == 1) remain.push(lst);
  long long mid = v / 2;
  if (mid == 0) return;
  stack<pair<int, int> > suck;
  long long got = customSetup2(suck, lst, 2);
  lst = getStatus2(suck);
  ans += got * mid;
  if (got == 0) return;
  go(lst, mid);
  return;
}
void finalPush() {
  stack<pair<int, int> > suck;
  while (!remain.empty()) {
    long long t = customSetup(suck, remain.top());
    ans += t;
    remain.pop();
  }
}
long long solve() {
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (m <= 2) {
    bruteForcesetup();
    long long ret = (n * m) - (ans * k);
    return ret;
  }
  vector<int> tmp;
  for (int i = 0; i < n; i++) tmp.push_back(a[i]);
  go(tmp, m);
  finalPush();
  long long ret = (n * m) - (ans * k);
  return ret;
}
int main() {
  long long q = solve();
  printf("%I64d\n", q);
  return 0;
}
