n,x,*a = map(int, open(0).read().split()) l=0 w=0 for v in a: if x<0:v=-v w+=max(0,min(abs(x),v)-max([0,v-30,l])) l=v print(w)