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 TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple& t) const {
    if (first != t.first) return first < t.first;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
template <class T>
void ResizeVec(T&, vector<long long>) {}
template <class T>
void ResizeVec(vector<T>& vec, vector<long long> sz) {
  vec.resize(sz[0]);
  sz.erase(sz.begin());
  if (sz.empty()) {
    return;
  }
  for (T& v : vec) {
    ResizeVec(v, sz);
  }
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, Triple<A, B, C> t) {
  return out << "(" << t.first << ", " << t.second << ", " << t.third << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
struct Reduct {
  vector<pair<long long, long long> > pref, suf;
  long long is_all;
  long long sz;
};
long long n, k, m;
pair<vector<pair<long long, long long> >, long long> Reduce(
    vector<pair<long long, long long> > v) {
  vector<pair<long long, long long> > first;
  long long res = 0;
  for (auto a : v) {
    if (first.empty() || first.back().first != a.first) {
      first.push_back(a);
    } else {
      first.back().second += a.second;
    }
    if (first.back().second >= k) {
      res += first.back().second / k;
      first.back().second %= k;
      if (first.back().second == 0) {
        first.pop_back();
      }
    }
  }
  return pair<vector<pair<long long, long long> >, long long>{first, res};
}
vector<pair<long long, long long> > Pref(
    vector<pair<long long, long long> > res) {
  res.resize(min(2 * n, ((long long)(res).size())));
  return res;
}
vector<pair<long long, long long> > Suf(
    vector<pair<long long, long long> > heh) {
  if (((long long)(heh).size()) <= 2 * n) {
    return heh;
  }
  vector<pair<long long, long long> > res;
  for (long long i = (((long long)(heh).size()) - 2 * n);
       i >= (((long long)(heh).size()) - 1); --i) {
    res.push_back(heh[i]);
  }
  return res;
}
Reduct Merge(Reduct a, Reduct b) {
  if (a.is_all && b.is_all) {
    vector<pair<long long, long long> > sum = a.pref;
    sum.insert(sum.end(), (b.pref).begin(), (b.pref).end());
    auto red = Reduce(sum);
    vector<pair<long long, long long> > reduct = red.first;
    long long grps = a.sz + b.sz + red.second;
    Reduct res;
    if (((long long)(reduct).size()) < 2 * n) {
      res.is_all = 1;
    } else {
      res.is_all = 0;
    }
    res.pref = Pref(reduct);
    res.suf = Suf(reduct);
    res.sz = grps;
    return res;
  } else {
    vector<pair<long long, long long> > sum = a.suf;
    sum.insert(sum.end(), (b.pref).begin(), (b.pref).end());
    auto red = Reduce(sum);
    return {a.pref, b.suf, 0, a.sz + b.sz + red.second};
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  if (0) cout << fixed << setprecision(10);
  cin.tie(0);
  cin >> n >> k >> m;
  vector<pair<long long, long long> > one_bus;
  for (long long i = (1); i <= (n); ++i) {
    long long a;
    cin >> a;
    one_bus.push_back({a, 1});
  }
  auto red = Reduce(one_bus);
  Reduct r{red.first, red.first, 1, red.second};
  long long lol = n * m;
  m--;
  Reduct a = r;
  while (m) {
    if (m % 2) {
      r = Merge(r, a);
    }
    a = Merge(a, a);
    m /= 2;
  }
  (a.sz, a.pref, a.is_all);
  cout << lol - k * r.sz << endl;
  return 0;
}
