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 long double pi = acosl(-1);
const int maxn = 100010;
const long long mod = 1e6 + 3;
const int inf = 1e9;
int n, k, m;
int a[maxn];
deque<pair<int, int> > vec;
void push(int city, int num) {
  if (!vec.empty() && city == vec.back().first) {
    vec.back().second += num;
    if (vec.back().second % k) {
      vec.back().second %= k;
    } else {
      vec.pop_back();
    }
  } else {
    vec.push_back({city, num});
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int cur = 0;
  for (int i = 1; i < n; i++) {
    if (a[cur] == a[i])
      continue;
    else {
      int num = i - cur;
      if (num % k) {
        push(a[cur], num % k);
      }
      cur = i;
    }
  }
  push(a[cur], (n - cur) % k);
  long long extra = 0;
  bool once = 0;
  if (vec.size() >= 2 && vec[0].first == vec.back().first) {
    extra = vec[0].second + vec.back().second;
  }
  while (vec.size() >= 2 && vec[0].first == vec.back().first) {
    if (vec[0].second + vec.back().second == k) {
      once = 1;
      vec.pop_back();
      vec.pop_front();
    } else if (vec[0].second + vec.back().second > k) {
      once = 1;
      int tmp = vec[0].second + vec.back().second - k;
      vec.back().second = 0;
      vec[0].second = tmp;
      break;
    } else {
      break;
    }
  }
  long long sum = 0;
  for (pair<int, int> i : vec) {
    sum += i.second;
  }
  if (vec.size() >= 2) {
    sum *= m;
    if (once) {
      sum += extra;
    }
  }
  if (vec.size() == 1) {
    sum = sum * m % k;
    if (once) {
      if (sum == 0) {
        sum = extra % k;
      } else {
        sum += extra;
      }
    }
  } else {
    if (once) {
      sum += extra % k;
    }
  }
  cout << sum << endl;
  return 0;
}
