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 long long int inf = 1e15;
const int M = 1e9 + 7;
std::vector<pair<long long int, long long int> > v;
int main() {
  ios::sync_with_stdio(false);
  long long int n, m, k, x;
  cin >> n >> k >> m;
  long long int a, cnt = 1;
  cin >> a;
  for (int i = 1; i < n; ++i) {
    cin >> x;
    if (a == x)
      cnt++;
    else {
      cnt = cnt % k;
      if (cnt != 0) v.push_back(make_pair(a, cnt));
      a = x;
      cnt = 1;
    }
  }
  cnt = cnt % k;
  if (cnt != 0) v.push_back(make_pair(a, cnt));
  a = x;
  cnt = 1;
  int end = v.size() - 1, start = 0;
  if (end == start) {
    cout << (m * v[0].second) % k << endl;
    return 0;
  }
  long long int sum = 0, e_sum, block;
  for (int i = 0; i <= end; ++i) sum += v[i].second;
  e_sum = 2 * sum;
  block = 0;
  if (m == 1) {
    cout << sum << endl;
    return 0;
  }
  while (true) {
    if (v[start].first == v[end].first && v[0].second + v[end].second == k &&
        end != start) {
      sum -= k;
      e_sum -= k;
      end--;
      start++;
    } else if (v[start].first == v[end].first &&
               v[0].second + v[end].second >= k && end != start) {
      sum -= k;
      e_sum -= k;
      break;
    } else if (end == start) {
      if (2 * v[start].second == k) {
        if (m % 2 == 0)
          e_sum = sum = 0;
        else
          e_sum = block, sum = 0;
        break;
      } else {
        if (m * v[start].second % k == 0)
          cout << 0;
        else
          cout << e_sum + m * v[start].second % k;
        return 0;
      }
    } else {
      break;
    }
  }
  if (m == 2) {
    cout << e_sum << endl;
  } else {
    m -= 2;
    cout << m * sum + e_sum << endl;
  }
  return 0;
}
