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;
int test;
vector<int> mpref, msuf, rpref, rsuf;
long long mcnt, rcnt;
int n, k, m;
int a[200000], inp[200000];
vector<int> tmp;
void mul(vector<int> &p, vector<int> &suf, vector<int> &pref, vector<int> &s,
         vector<int> &rpref, vector<int> &rsuf, long long a, long long b,
         long long &c) {
  int ind = (int)suf.size() - 1;
  int jnd = 0;
  while (ind >= 0) {
    int iind = ind;
    int jjnd = jnd;
    int cnt = 0;
    while (cnt < k && iind >= 0 && suf[iind] == suf[ind]) {
      ++cnt;
      --iind;
    }
    while (cnt < k && jjnd < (int)pref.size() && pref[jjnd] == suf[ind]) {
      ++cnt;
      ++jjnd;
    }
    if (cnt == k) {
      ind = iind;
      jnd = jjnd;
    } else {
      break;
    }
  }
  a -= (int)suf.size() - 1 - ind;
  b -= jnd;
  tmp.clear();
  int aa = min(a, (long long)p.size());
  for (int i = 0; i < (int)(aa); ++i) {
    tmp.push_back(p[i]);
  }
  int bb = min(b, (long long)s.size());
  for (int i = 0; i < (int)(bb); ++i) {
    tmp.push_back(s[(int)s.size() - bb + i]);
  }
  c = a + b;
  aa = min(2 * n + 111, (int)tmp.size());
  rpref.clear();
  rsuf.clear();
  for (int i = 0; i < (int)(aa); ++i) rpref.push_back(tmp[i]);
  for (int i = 0; i < (int)(aa); ++i)
    rsuf.push_back(tmp[(int)tmp.size() - aa + i]);
}
void binPow(int p) {
  rpref.clear();
  rsuf.clear();
  rcnt = 0;
  while (p) {
    if (p & 1) mul(rpref, rsuf, mpref, msuf, rpref, rsuf, rcnt, mcnt, rcnt);
    p >>= 1;
    if (p) mul(mpref, msuf, mpref, msuf, mpref, msuf, mcnt, mcnt, mcnt);
  }
}
vector<int> st;
long long solve() {
  int last = -1;
  int cnt = 0;
  st.clear();
  int pos = 0;
  int nn = n;
  for (int i = 0; i < n; ++i) {
    a[i] = inp[pos++];
    if (a[i] != last) {
      if (last != -1) {
        st.push_back(cnt);
      }
      last = a[i];
      cnt = 0;
    }
    if (++cnt == k) {
      i -= k;
      n -= k;
      if (st.empty()) {
        last = -1;
        cnt = 0;
      } else {
        last = a[i];
        cnt = st.back();
        st.pop_back();
      }
    }
  }
  if (st.empty()) {
    n = nn;
    return (long long)n * m % k;
  }
  mpref.clear();
  msuf.clear();
  for (int i = 0; i < (int)(n); ++i) mpref.push_back(a[i]);
  for (int i = 0; i < (int)(n); ++i) msuf.push_back(a[i]);
  mcnt = n;
  binPow(m);
  n = nn;
  return rcnt;
}
void readTest() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", inp + i);
  }
}
mt19937 mt(123);
void genTest() {
  n = mt() % 25 + 1;
  k = mt() % 25 + 1;
  m = mt() % 25 + 1;
  int cnt = mt() % 25 + 1;
  for (int i = 0; i < (int)(n); ++i) {
    inp[i] = mt() % cnt + 1;
  }
}
long long brute() {
  int last = -1;
  int cnt = 0;
  st.clear();
  int nn = n;
  int ind = 0;
  for (int _ = 0; _ < (int)(m); ++_) {
    int pos = 0;
    n = ind + nn;
    for (int i = ind; i < n; ++i) {
      a[i] = inp[pos++];
      if (a[i] != last) {
        if (last != -1) {
          st.push_back(cnt);
        }
        last = a[i];
        cnt = 0;
      }
      if (++cnt == k) {
        i -= k;
        n -= k;
        if (st.empty()) {
          last = -1;
          cnt = 0;
        } else {
          last = a[i];
          cnt = st.back();
          st.pop_back();
        }
      }
    }
    ind = n;
  }
  n = nn;
  return ind;
}
int main() {
  readTest();
  cout << solve() << endl;
  return 0;
}
