def solve():
    N,L=map(int,input().split())
    a=[0]+[L-int(input())for _ in[0]*N]
    l=[]
    cumsum,dir=0,0
    for n,prev in zip(a[1:],a):
        if dir==0 and n>prev or dir==1 and n<prev:
            cumsum+=n
        else:
            l.append(cumsum)
            cumsum=n+prev
            dir^=1
    else:
        l.append(cumsum)
    print(max(l))
if __name__=="__main__":
    solve()

