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;
vector<int> inlist, outlist;
stack<pair<int, int> > s1, s2;
int n, k, m, ai;
vector<int> solve() {
  outlist.clear();
  for (int i = 0; i < inlist.size(); i++) {
    if (s1.empty()) {
      s1.push(make_pair(inlist[i], 1));
      continue;
    }
    pair<int, int> last = s1.top();
    if (inlist[i] == last.first) {
      if ((last.second + 1) % k == 0) {
        s1.pop();
      } else {
        last.second++;
        s1.pop();
        s1.push(last);
      }
    } else {
      last.first = inlist[i];
      last.second = 1;
      s1.push(last);
    }
  }
  while (!s1.empty()) {
    pair<int, int> top = s1.top();
    s2.push(top);
    s1.pop();
  }
  int start_printing = false;
  while (!s2.empty()) {
    pair<int, int> top = s2.top();
    for (int i = 0; i < top.second; i++) {
      outlist.push_back(top.first);
    }
    s2.pop();
  }
  return outlist;
}
int main() {
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ai);
    inlist.push_back(ai);
  }
  unsigned long long remaining = (unsigned long long)n * (unsigned long long)m;
  solve();
  if (outlist.size() == 0)
    remaining = 0LL;
  else {
    if (m == 1)
      remaining = outlist.size();
    else {
      remaining -= ((unsigned long long)inlist.size() -
                    (unsigned long long)outlist.size()) *
                   (long long)m;
      int count = 0;
      bool started = false;
      bool repeatdone = false;
      for (int i = outlist.size() - 1, j = 0; i >= 0 && j < outlist.size();) {
        if (outlist[i] != outlist[j])
          break;
        else if (started == false) {
          count = 2;
          started = true;
        }
        int nexti, nextj;
        if (i == 0)
          nexti = -1;
        else
          nexti = outlist[i - 1];
        if (j == outlist.size() - 1)
          nextj = -2;
        else
          nextj = outlist[j + 1];
        if (nexti == outlist[i] && nextj == outlist[j]) {
          i--;
          j++;
          count += 2;
        } else if (nextj == outlist[j]) {
          j++;
          count++;
        } else if (nexti == outlist[i]) {
          i--;
          count++;
        } else {
          if (i > j || repeatdone == true) {
            if (count >= k) {
              unsigned long long total = 0LL;
              if (repeatdone == false)
                total = ((unsigned long long)count -
                         ((unsigned long long)count % (unsigned long long)k)) *
                        ((unsigned long long)m - 1);
              else
                total = ((unsigned long long)count -
                         ((unsigned long long)count % (unsigned long long)k));
              remaining -= total;
            }
            if (count % k == 0) {
              i--;
              j++;
              started = false;
              count = 0;
              continue;
            } else
              break;
          } else {
            repeatdone = true;
            unsigned long long cnt =
                ((unsigned long long)count / 2) * (unsigned long long)m;
            if (cnt >= k) {
              unsigned long long total =
                  ((unsigned long long)count / 2 * (unsigned long long)m) -
                  ((((unsigned long long)count / 2) * (unsigned long long)m) %
                   (unsigned long long)k);
              remaining -= total;
            }
            if (cnt % k == 0) {
              i--;
              j++;
              started = false;
              count = 0;
              continue;
            } else
              break;
          }
        }
      }
      int x = 0;
    }
  }
  printf("%llu\n", remaining);
}
