#include <bits/stdc++.h>   using namespace std;   int Set(int N, int pos) { return N |= (1LL << pos); }   int Reset(int N, int pos) { return N &= ~(1LL << pos); }   bool Check(int N, int pos) { return N & (1LL << pos); }   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1};   inline void cn(long &n) {     n = 0;     long ch = getchar();     int sign = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) sign = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       n = (n << 3) + (n << 1) + ch -  0 , ch = getchar();     n = n * sign;   }   template <class T>   void cmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   void cmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   int len(const T &c) {     return (int)c.size();   }   template <class T>   int len(char c[]) {     return (int)strlen(c);   }   long stoi(string s) {     long n = 0;     for (int i(0), _n(len(s)); i < _n; ++i) n = n * 10 + (s[i] - 48);     return n;   }   int main() {     ios_base::sync_with_stdio(false);     long m, t, r, w, k, ww, res = 0, ls;     cin >> m >> t >> r;     vector<int> v, tem;     int f = 1;     for (int i(0), _n(m); i < _n; ++i) {       cin >> w;       ls = -100000000000000000LL;       if (!f) continue;       for (int j = len(v) - 1; j >= 0; j--) {         if (v[j] >= w)           tem.push_back(v[j]);         else           break;       }       if (len(tem) < r) {         k = r - len(tem);         ww = w;         for (int j(0), _n(k); j < _n; ++j) {           if (ww + t - 1 >= w) {             res++;             tem.push_back(ww + t - 1);             ww -= 1;           } else {             f = 0;             break;           }         }       }       v = tem;       tem.clear();       sort(v.begin(), v.end());     }     if (f == 0) res = -1;     cout << res;     return 0;   }   