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 = 100100;
int n, k, m, s[N];
deque<pair<int, int> > a;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> m;
  for (int i = (1); i <= (n); i++) {
    cin >> s[i];
  }
  long long ans = 0;
  for (int i = (1); i <= (n); i++) {
    if (a.size() == 0 || s[i] != a.back().first) {
      a.push_back({s[i], 1});
    } else {
      a.back().second++;
      if (a.back().second == k) {
        ans += m;
        a.pop_back();
      }
    }
  }
  if (a.size() == 0)
    cout << 0 << endl;
  else if (a.size() == 1)
    cout << (long long)n * m % k << endl;
  else {
    auto b = a;
    while (b.size() > 1 && b.front().first == b.back().first) {
      if (b.front().second + b.back().second >= k) {
        ans += m - 1;
      }
      if ((b.front().second + b.back().second) % k)
        break;
      else {
        b.pop_front();
        b.pop_back();
      }
    }
    if (b.size() == 1) {
      ans += (long long)b.front().second * m / k;
      if ((long long)b.front().second * m % k == 0) {
        cout << (long long)n * m % k << endl;
        return 0;
      }
    } else if (b.size() == 0) {
      cout << (long long)n * m % k << endl;
      return 0;
    }
    cout << (long long)n * m - ans * k << endl;
  }
  return 0;
}
