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;
pair<int, int> p[100001];
int main() {
  int n, k, m;
  scanf("%d %d %d", &n, &k, &m);
  int c = -1, d;
  int index = 1;
  int next;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &next);
    if (c == -1) {
      c = next;
      d = 1;
    } else {
      if (next == c) {
        d++;
      } else {
        p[index].first = c;
        p[index].second = d;
        c = next;
        d = 1;
        index++;
      }
    }
  }
  p[index].first = c;
  p[index].second = d;
  int i = 1;
  int p_count = 0;
  while (i <= index) {
    if (p[i].first == p[index + 1 - i].first) {
      if ((p[i].second + p[index + 1 - i].second) % k == 0) {
        p_count = i;
        p[i].second = (p[i].second % k);
        p[index + 1 - i].second = (p[index + 1 - i].second % k);
        i++;
      } else {
        break;
      }
    } else {
      break;
    }
  }
  if (p_count >= index / 2) {
    if (index % 2 == 0) {
      printf("%d", 0);
    } else {
      int med = index / 2;
      long long dmed = p[med + 1].second * m;
      long long remainder = (dmed % k);
      if (remainder == 0) {
        printf("%d", 0);
      } else {
        for (int i = 1; i <= index; i++) {
          if (i != med + 1) remainder = remainder + (p[i].second % k);
        }
        printf("%lld", remainder);
      }
    }
  } else {
    long long remainder = 0;
    for (int i = 1; i <= p_count; i++) {
      remainder = remainder + p[i].second;
    }
    for (int i = index; i >= index + 1 - p_count; i--) {
      remainder = remainder + p[i].second;
    }
    long long inter_remainder = 0;
    for (int i = p_count + 1; i < index + 1 - p_count; i++) {
      inter_remainder = inter_remainder + (p[i].second % k);
    }
    remainder = remainder + inter_remainder * m;
    long long minus = 0;
    if (p[p_count + 1].first == p[index - p_count].first) {
      if (((p[p_count + 1].second % k) + (p[index - p_count].second % k)) > k) {
        minus = k;
      }
    }
    printf("%lld", remainder - minus * (m - 1));
  }
  return 0;
}
