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 MAXN = 1e6;
char type[MAXN];
int value[MAXN];
int to_do[MAXN];
int k;
int sz[MAXN], par[MAXN];
vector<int> components[MAXN];
int root(int v) {
  if (par[v] == v) return v;
  return par[v] = root(par[v]);
}
void unite(int a, int b) {
  a = root(a), b = root(b);
  if (a == b) return;
  if (sz[a] < sz[b]) swap(a, b);
  par[b] = a;
  sz[a] += sz[b];
}
vector<int> dup(vector<int> &original) {
  int sz = original.size();
  vector<int> answer(2 * sz);
  for (int i = 0; i < sz; i++) answer[i] = answer[i + sz] = original[i];
  return answer;
}
vector<int> clean(vector<int> &v, int &taken_out) {
  int e;
  vector<int> cleared;
  bool flag = true;
  int n = v.size();
  taken_out = 0;
  set<int> alive;
  for (int i = 0; i < n; i++) {
    par[i] = i;
    sz[i] = 1;
    alive.insert(i);
    components[i].clear();
    components[i].push_back(i);
  }
  for (int i = 1; i < n; i++) {
    set<int>::iterator before = alive.lower_bound(i);
    if (before == alive.begin()) continue;
    before--;
    int prev = *before;
    if (v[i] == v[prev]) {
      int comp = root(prev);
      if (sz[comp] == k) continue;
      unite(prev, i);
      comp = root(prev);
      components[comp].push_back(i);
      if (sz[comp] == k) {
        for (int i = 0; i < components[comp].size(); i++) {
          alive.erase(components[comp][i]);
        }
      }
    }
  }
  taken_out = n;
  for (set<int>::iterator it = alive.begin(); it != alive.end(); it++) {
    cleared.push_back(v[*it]);
    taken_out--;
  }
  return cleared;
}
int main() {
  int n, m;
  scanf("%d %d %d\n", &n, &k, &m);
  long long total_people = 1LL * n * m;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  vector<int> cc = v;
  sort(cc.begin(), cc.end());
  cc.erase(unique(cc.begin(), cc.end()), cc.end());
  if (cc.size() == 1) {
    printf("%lld\n", total_people % k);
    return 0;
  }
  int out;
  vector<int> cleared = clean(v, out);
  cc = cleared;
  sort(cc.begin(), cc.end());
  cc.erase(unique(cc.begin(), cc.end()), cc.end());
  if (cc.size() == 1) {
    int sz = cc.size();
    total_people = 1LL * sz * m;
    printf("%lld\n", total_people % k);
  }
  vector<int> dup_twice = dup(cleared);
  cleared = clean(dup_twice, out);
  cc = cleared;
  sort(cc.begin(), cc.end());
  cc.erase(unique(cc.begin(), cc.end()), cc.end());
  if (cc.size() == 1) {
    int sz = cc.size();
    total_people = 1LL * sz * (m / 2);
    printf("%lld\n", total_people % k);
  }
  int sz = cleared.size();
  total_people = 1LL * sz * (m / 2) + n;
  for (int i = 0; i < n; i++) cleared.push_back(v[i]);
  clean(cleared, out);
  total_people -= out;
  printf("%lld\n", total_people);
  return 0;
}
