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;
class group {
 public:
  int number;
  long long int count;
};
int main(int argc, char const *argv[]) {
  long long int k, m;
  int n;
  cin >> n >> k >> m;
  std::vector<int> num(n);
  long long int count = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
  }
  std::vector<group> groups;
  for (int i = 1; i < n; ++i) {
    if (num[i] == num[i - 1]) {
      count++;
    } else {
      group temp;
      temp.number = num[i - 1];
      temp.count = count;
      groups.push_back(temp);
      count = 1;
    }
  }
  group temp;
  temp.number = num[n - 1];
  temp.count = count;
  groups.push_back(temp);
  int start = 0, end = groups.size() - 1;
  int middle = n;
  int flag = 0;
  while (middle != 0 && start < end) {
    if (groups[end].number == groups[start].number) {
      if (groups[end].count + groups[start].count == k) {
        middle -= k;
        ++start;
        --end;
      } else if (groups[end].count + groups[start].count >= k) {
        middle -= k;
        ++start;
        --end;
        flag = 1;
        break;
      }
    } else
      break;
  }
  long long int result = middle * (m - 2);
  for (int i = 0; i <= end; ++i) {
    result += groups[i].count % k;
  }
  for (int i = start; i < groups.size(); ++i) {
    result += groups[i].count % k;
  }
  if (flag == 1) {
    result += (groups[end + 1].count + groups[start - 1].count - k);
  }
  if (start == end && flag == 0) {
    result = result % k;
  }
  cout << result << endl;
  return 0;
}
