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;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N, K, M;
int A[100111];
void task_same() {
  long long z = (long long)N * M;
  printf("%lld\n", z % K);
}
deque<pair<int, long long> > cat(deque<pair<int, long long> > x,
                                 const deque<pair<int, long long> > &y) {
  for (__typeof((y).begin()) e = (y).begin(), e_end = (y).end(); e != e_end;
       ++e) {
    if (x.size() && x.back().first == e->first) {
      x.back().second += e->second;
      x.back().second %= K;
      if (x.back().second == 0) x.pop_back();
    } else {
      x.push_back(*e);
    }
  }
  return x;
}
void task() {
  deque<pair<int, long long> > head, mid, tail;
  long long cnt = 1;
  int last = A[0];
  for (int i = 1; i < N; i++) {
    if (A[i] != last) {
      cnt %= K;
      if (cnt) {
        if (!mid.empty() && mid.back().first == last) {
          mid.back().second += cnt;
          mid.back().second %= K;
          if (mid.back().second == 0) mid.pop_back();
        } else {
          mid.push_back(make_pair(last, cnt));
        }
      }
      last = A[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  cnt %= K;
  if (cnt) {
    if (!mid.empty() && mid.back().first == last) {
      mid.back().second += cnt;
      mid.back().second %= K;
      if (mid.back().second == 0) mid.pop_back();
    } else {
      mid.push_back(make_pair(last, cnt));
    }
  }
  long long left = 0;
  if (M == 1) {
    for (__typeof((mid).begin()) e = (mid).begin(), e_end = (mid).end();
         e != e_end; ++e)
      left += e->second;
  } else if (M == 2) {
    mid = cat(mid, mid);
    for (__typeof((mid).begin()) e = (mid).begin(), e_end = (mid).end();
         e != e_end; ++e)
      left += e->second;
  } else {
    head = tail = mid;
    M -= 2;
    while (!head.empty() && mid.size() >= 2u &&
           head.back().first == mid[0].first) {
      assert(head.back().second == mid.back().second);
      assert(mid[0].second == tail[0].second);
      head.back().second += mid[0].second;
      mid.back().second += tail[0].second;
      mid.pop_front();
      tail.pop_front();
      head.back().second %= K;
      mid.back().second %= K;
      if (head.back().second == 0) {
        head.pop_back();
        mid.pop_back();
      }
    }
    if (mid.size() <= 1u) {
      if (mid.empty()) {
        head = cat(head, tail);
      } else {
        mid.back().second = (long long)mid.back().second * M % K;
        head = cat(head, cat(mid, tail));
      }
      for (__typeof((head).begin()) e = (head).begin(), e_end = (head).end();
           e != e_end; ++e)
        left += e->second;
    } else {
      for (__typeof((head).begin()) e = (head).begin(), e_end = (head).end();
           e != e_end; ++e)
        left += e->second;
      for (__typeof((mid).begin()) e = (mid).begin(), e_end = (mid).end();
           e != e_end; ++e)
        left += (long long)e->second * M;
      for (__typeof((tail).begin()) e = (tail).begin(), e_end = (tail).end();
           e != e_end; ++e)
        left += e->second;
    }
  }
  printf("%lld\n", left);
}
void MAIN() {
  scanf("%d%d%d", &N, &K, &M);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d", A + i);
  bool same = true;
  for (int i = 0, i_len = (N - 1); i < i_len; ++i)
    if (A[i] != A[i + 1]) same = false;
  if (same)
    task_same();
  else
    task();
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
