#include <bits/stdc++.h>
using namespace std;
pair<int, int> *arr = new pair<int, int>[100001];
long long county(int left, long long n, long long k, long long m) {
  if (arr[left].first == arr[n - 1 - left].first) {
    if (left == n - 1 - left) {
      return (long long)((m * arr[left].second) % k);
    }
    if (arr[left].second + arr[n - 1 - left].second == k) {
      long long result = k + county(left + 1, n, k, m);
      if (result == k)
        return 0;
      else
        return result;
    }
    if (arr[left].second + arr[n - 1 - left].second > k) {
      long long sum = 0;
      for (int i = left + 1; i <= n - 2 - left; i++) {
        sum += arr[i].second;
      }
      return (
          long long)(m * sum + arr[left].second + arr[n - 1 - left].second +
                     (m - 1) *
                         ((arr[left].second + arr[n - 1 - left].second) % k));
    }
    if (arr[left].second + arr[n - 1 - left].second < k) {
      long long sum = 0;
      for (int i = left; i <= n - 1 - left; i++) {
        sum += arr[i].second;
      }
      return sum * m;
    }
  } else {
    long long sum = 0;
    for (int i = left; i <= n - 1 - left; i++) {
      sum += arr[i].second;
    }
    return (long long)(sum * m);
  }
}
int main() {
  long long n, k, m;
  cin >> n;
  cin >> k;
  cin >> m;
  int count = 0;
  for (int i = 0; i < n; i++) {
    int number;
    cin >> number;
    if (i == 0) {
      arr[count] = make_pair(number, 1);
      continue;
    }
    if (number == arr[count].first) {
      arr[count].second++;
      if (arr[count].second == k) {
        if (count == 0) {
          arr[count].second = 0;
        } else
          count--;
      }
    } else {
      count++;
      arr[count] = make_pair(number, 1);
    }
  }
  if (count == 0) {
    if (arr[count].second == 0) {
      cout << 0;
      return 0;
    }
  }
  if (arr[0].second == 0) {
    cout << county(1, count + 2, k, m);
    return 0;
  }
  long long answer = county(0, count + 1, k, m);
  cout << answer;
  return 0;
}
