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 = 1e5 + 7;
int n, k, m, a[N];
int gao(const vector<pair<int, int> > &x) {
  int ret = 0;
  for (int i = ((int)(x).size()) - 1, j = 0; i >= 0; --i, ++j) {
    if (x[i].first != x[j].first) break;
    if (x[i].second + x[j].second != k) break;
    ++ret;
  }
  return ret;
}
long long solve() {
  long long ret = 0;
  vector<pair<int, int> > v;
  for (int i = 0, j = 1; i < n; i = j++) {
    while (j < n && a[j] == a[i]) ++j;
    if ((j - i) % k > 0) {
      v.push_back(make_pair(a[i], (j - i) % k));
      ret += v.back().second;
    }
  }
  if (m == 1) return ret;
  if (((int)(v).size()) == 1) {
    ret = 1ll * v.back().second * m % k;
    return ret;
  }
  int p = gao(v);
  if (p <= (((int)(v).size()) - 1) / 2) {
    ret = 1ll * ret * m - 1ll * p * k * (m - 1);
  } else if (p == ((int)(v).size())) {
    return 0;
  } else {
    return -1;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  cout << solve() << endl;
  return 0;
}
