def solve():

  n,l = list(map(int,input().split()))

  

  length = [int(eval(input())) for i in range(n)]

  pare = [(length[i], i) for i in range(n)]

  pare.sort(reverse=True)

  dp = [0] * (n + 1)

  for p in pare:

    i = p[1]

    if i == 0:

      dp[i] = dp[i + 1] + (l - length[i])

    else:

      dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])

  print((max(dp)))

solve()

n, l = list(map(int,input().split()))

ans = 0

pre = 0

up_acc = 0

down_acc = 0

for i in range(n):

  length = int(eval(input()))

  time = l - length

  if length > pre:

    up_acc += time

    if down_acc > ans:

      ans = down_acc

    down_acc = time

  else:

    down_acc += time

    if up_acc > ans:

      ans = up_acc

    up_acc = time

  pre = length

else:

  ans = max(ans, up_acc, down_acc)

print(ans)

def solve():
    n, l = list(map(int, input().split()))
    length = [int(eval(input())) for i in range(n)]
    pare = [(length[i], i) for i in range(n)]
    pare.sort(reverse=True)
    dp = [0] * (n + 1)
    for p in pare:
        i = p[1]
        if i == 0:
            dp[i] = dp[i + 1] + (l - length[i])
        else:
            dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])
    print((max(dp)))


solve()

n, l = list(map(int, input().split()))
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
    length = int(eval(input()))
    time = l - length
    if length > pre:
        up_acc += time
        if down_acc > ans:
            ans = down_acc
        down_acc = time
    else:
        down_acc += time
        if up_acc > ans:
            ans = up_acc
        up_acc = time
    pre = length
else:
    ans = max(ans, up_acc, down_acc)
print(ans)

-def solve(): -    n, l = list(map(int, input().split())) -    length = [int(eval(input())) for i in range(n)] -    pare = [(length[i], i) for i in range(n)] -    pare.sort(reverse=True) -    dp = [0] * (n + 1) -    for p in pare: -        i = p[1] -        if i == 0: -            dp[i] = dp[i + 1] + (l - length[i]) -        else: -            dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i]) -    print((max(dp))) - - -solve() +n, l = list(map(int, input().split())) +ans = 0 +pre = 0 +up_acc = 0 +down_acc = 0 +for i in range(n): +    length = int(eval(input())) +    time = l - length +    if length > pre: +        up_acc += time +        if down_acc > ans: +            ans = down_acc +        down_acc = time +    else: +        down_acc += time +        if up_acc > ans: +            ans = up_acc +        up_acc = time +    pre = length +else: +    ans = max(ans, up_acc, down_acc) +print(ans)