#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } int main() { int N; int L; while(~scanf("%d%d", &N, &L)) { vector X(N); X[0] = 0; for(int i = 1; i < N; ++ i) scanf("%d", &X[i]); int ans = 0; ll num = 0; int den = 0; for(int i = N - 1; i >= 0; -- i) { if(i < N - 1) { if(num <= (ll)X[i] * den || (ll)(X[i] + L) * den <= num || num <= (ll)X[i + 1] * den || (ll)(X[i + 1] + L) * den <= num) ++ ans; if(X[i] + L <= X[i + 1] || X[i + 1] + L <= X[i]) { ans = -1; break; } } num += X[i] * 2 + L; den += 2; } printf("%d\n", ans); } return 0; }