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;
template <typename T>
void resize(int n, vector<T> &u) {
  u.resize(n);
}
template <typename Head, typename... Tail>
void resize(int n, Head &H, Tail &...T) {
  resize(n, H);
  resize(n, T...);
}
template <typename T>
void debug_out(T t) {
  cerr << t;
}
template <typename A, typename B>
void debug_out(pair<A, B> &u) {
  cerr << "(" << u.first << " " << u.second << ")";
}
template <typename T>
void debug_out(vector<T> &t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << ", ";
  }
}
template <typename T>
void debug_out(vector<vector<T>> &t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << endl;
  }
}
vector<char> lowchar = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                        'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                        's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
vector<char> hichar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                       'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                       'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> base_10 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
template <typename T>
string to_string(T t) {
  ostringstream ss;
  ss << t;
  return ss.str();
}
long long to_num(string t) {
  long long res = 0;
  for (int i = 0; i < (int)t.length(); i++) {
    res *= 10;
    res += t[i] - '0';
  }
  return res;
}
int n, k, m;
long long res;
deque<pair<int, int>> a;
vector<pair<int, int>> cur;
void deplete(vector<pair<int, int>> &s) {
  vector<pair<int, int>> repel;
  for (int i = 0; i < (int)s.size(); i++) {
    if (repel.empty() || repel.back().first != s[i].first)
      repel.push_back(s[i]);
    else
      repel.back().second += s[i].second;
    repel.back().second %= k;
    if (repel.back().second == 0) repel.pop_back();
  }
  s = repel;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    if (cur.empty() || cur.back().first != c)
      cur.emplace_back(c, 1);
    else
      cur.back().second++;
  }
  deplete(cur);
  int l = 0, r = cur.size() - 1;
  while (cur[l].first == cur[r].first && cur[r].second + cur[l].second == k &&
         r > l) {
    res += k;
    l++;
    r--;
  }
  if (r > l) {
    int aux = 0;
    for (int i = l; i <= r; i++) aux += cur[i].second;
    if (cur[l].first == cur[r].first && cur[l].second + cur[r].second > k) {
      res += cur[l].second + cur[r].second;
      long long sp = cur[l].second + cur[r].second - k;
      aux -= k;
      cout << 1LL * m * aux + res + (m - 1) * sp;
      return 0;
    }
    cout << 1LL * m * aux + res;
  } else {
    long long aux = cur[l].second;
    aux = (aux * m) % k;
    if (aux == 0) {
      cout << 0;
    } else {
      cout << aux + res;
    }
  }
  return 0;
}
