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 int N = 5e5 + 10;
const int inf = 1e18 + 5;
const int mod = 1e9 + 7;
int n, k, m;
void reverse(stack<pair<int, long long> >& st) {
  stack<pair<int, long long> > stt;
  while (!st.empty()) {
    stt.push(st.top());
    st.pop();
  }
  st = stt;
}
void go(stack<pair<int, long long> >& a, stack<pair<int, long long> > b) {
  reverse(b);
  while (!b.empty()) {
    auto cur = b.top();
    b.pop();
    if (a.empty()) {
      a.push(cur);
    } else {
      a.push(cur);
      while (a.size() >= 2) {
        auto cur1 = a.top();
        a.pop();
        auto cur2 = a.top();
        a.pop();
        if (cur1.first != cur2.first) {
          a.push(cur2);
          a.push(cur1);
          break;
        } else {
          cur1.second += cur2.second;
          cur1.second %= k;
          if (cur1.second) {
            a.push(cur1);
          }
        }
      }
    }
  }
}
long long sz(stack<pair<int, long long> > a) {
  long long res = 0;
  while (!a.empty()) {
    res += a.top().second;
    a.pop();
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> m;
  stack<pair<int, long long> > cur;
  stack<pair<int, long long> > res;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    stack<pair<int, long long> > tmp;
    tmp.push({x, 1});
    go(cur, tmp);
  }
  stack<pair<int, long long> > dd = cur;
  if (k > 1e5 && cur.size() == 1) {
    cout << (n * 1ll * m) % k << endl;
  } else if (k > 1e5) {
    cout << n * 1ll * m << endl;
  } else {
    bool flag = 0;
    int mm = m;
    while (m) {
      if (m & 1) {
        go(res, cur);
      }
      go(cur, cur);
      if (cur.size() > 2 * n) {
        flag = 1;
        break;
      }
      m /= 2;
    }
    if (!flag) {
      cout << sz(res) << endl;
    } else {
      long long fi = sz(dd);
      go(dd, dd);
      long long dif = sz(dd) - fi;
      cout << fi + dif * (mm - 1) << endl;
    }
  }
  return 0;
}
