#!/usr/bin/env python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np # %% N = int(readline()) L = int(readline()) X = np.array([0] + read().split(), np.int64) # %% X = X[::-1] # %% def solve(X): if np.any(np.abs(np.diff(X)) >= L): return - 1 Xcum = np.cumsum(X) M = (2 * Xcum + np.arange(1, N + 1) * L)[:-1] LHS = np.maximum(2 * X[:-1], 2 * X[1:]) * np.arange(1, N) RHS = np.minimum(2 * X[:-1], 2 * X[1:]) * np.arange(1, N) + np.arange(1, N) * L * 2 omit = (LHS < M) & (M < RHS) return N - 1 - np.count_nonzero(omit) # %% print(solve(X))