n,t = map(int,input().split())
d = [int(i) for i in input().split()]
# print(n,t,d)
sco = 0
while True:
cd = [ i for i in d if i!=0 and i<=t]
if sum(cd)==0:break
cv = min(cd)
ci = d.index(cv)
if ci == n-1:
sco+=d[ci]
d[ci]=0
continue
else:
oi =ci+1
while oi < n-1 and d[oi]==0:
oi+=1
if d[oi]==0 and oi == n-1:
sco +=d[ci]
d[ci]=0
continue
d[oi]+=d[ci]
sco +=d[ci]
d[ci]=0
print(sco)
# data:
# 5 4
# 4 4 3 2 1
# Output:
# 10
沒有留言:
張貼留言