from itertools import accumulate import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) L = int(input()) * 2 X = [0] + [int(input()) * 2 for _ in range(N-1)] # 破綻してないかチェック if any(abs(a - b) >= L for a, b in zip(X[:-1], X[1:])): print(-1) exit() def safe(i, n, g): return n * left[i] < g and g < n * right[i] right = [c + L // 2 for c in X] left = [c - L // 2 for c in X] ans = 0 g = 0 # 重心 n = 0 # 上にあるパネル数 for i in reversed(range(1, N)): n += 1 g += X[i] if safe(i, n, g) and safe(i - 1, n, g): continue ans += 1 print(ans)