def orderN(N,L,ices):

    upPeak = L - ices[0]

    downPeak = L - ices[0]

    peaks = []

    for i in range(len(ices)):

        if i < N-1:

            if ices[i] < ices[i+1]:

                peaks.append(downPeak)

                downPeak = L - ices[i+1]

                upPeak += L - ices[i+1]

            else:

                peaks.append(upPeak)

                upPeak = L - ices[i+1]

                downPeak += L - ices[i+1]

        else:

            peaks.append(upPeak)

            peaks.append(downPeak)

    print((max(peaks)))



N,L = list(map(int,input().strip().split()))

ices = []

while True:

    ice = int(input().strip())

    ices.append(ice)

    if len(ices) == N:

        break



orderN(N,L,ices)
def orderN(N,L,ices):

    upPeak = L - ices[0]

    downPeak = L - ices[0]

    peaks = []

    for i in range(len(ices)):

        if i < N-1:

            if ices[i] < ices[i+1]:

                peaks.append(downPeak)

                downPeak = L - ices[i+1]

                upPeak += L - ices[i+1]

            else:

                peaks.append(upPeak)

                upPeak = L - ices[i+1]

                downPeak += L - ices[i+1]

        else:

            peaks.append(upPeak)

            peaks.append(downPeak)

    print((max(peaks)))



N,L = list(map(int,input().strip().split()))

ices = [int(input().strip()) for _ in range(N)]



orderN(N,L,ices)
def orderN(N, L, ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in range(len(ices)):
        if i < N - 1:
            if ices[i] < ices[i + 1]:
                peaks.append(downPeak)
                downPeak = L - ices[i + 1]
                upPeak += L - ices[i + 1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i + 1]
                downPeak += L - ices[i + 1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print((max(peaks)))


N, L = list(map(int, input().strip().split()))
ices = []
while True:
    ice = int(input().strip())
    ices.append(ice)
    if len(ices) == N:
        break
orderN(N, L, ices)

def orderN(N, L, ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in range(len(ices)):
        if i < N - 1:
            if ices[i] < ices[i + 1]:
                peaks.append(downPeak)
                downPeak = L - ices[i + 1]
                upPeak += L - ices[i + 1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i + 1]
                downPeak += L - ices[i + 1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print((max(peaks)))


N, L = list(map(int, input().strip().split()))
ices = [int(input().strip()) for _ in range(N)]
orderN(N, L, ices)

-ices = [] -while True: -    ice = int(input().strip()) -    ices.append(ice) -    if len(ices) == N: -        break +ices = [int(input().strip()) for _ in range(N)]