Harryxun/stf_run huggingface dataset:
import math
N = int(input())
A = list(map(int, input().split()))

X1 = [0] * (N+2)
X2 = [0] * (N+2)

for i in range(N):
    X1[i+1] = math.gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = math.gcd(X2[i+1], A[i-1])

ans = 1
for i in range(N):
    gcd = math.gcd(X1[i], X2[i+2])
    if ans < gcd:
        ans = gcd
print(ans)


### FIXED CODE ###

from fractions import *
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
b = [0] * (n+2)
c = [0] * (n+2)

for i in range(1, n+1):
    b[i] = gcd(b[i-1], a[i])
for i in range(n,0,-1):
    c[i] = gcd(c[i+1], a[i])

ans = 1
for i in range(1, n+1):
    if ans < gcd(b[i-1], c[i+1]):
        ans = gcd(b[i-1], c[i+1])
print(ans)
l = raw_int(input()).split()

if l[0] < l[1]:
  print("<")
elif l[0] = l[1]:
  print ("=")
elif l[0] > l[1]:
  print(">")

### FIXED CODE ###

l = input().split()
l2 = [int(s, 16) for s in l]

if l2[0] < l2[1]:
  print("<")
elif l2[0] == l2[1]:
  print ("=")
elif l2[0] > l2[1]:
  print(">")
a=Int(input())
S=input()

if(A>=3200):
  print(S)
else:
  print("red")

### FIXED CODE ###

a=int(input())
S=input()

if(a>=3200):
  print(S)
else:
  print("red")
import math
r = float(input())
v =2*math.pi*r
s =math.pi*r^2

print(v,s)


### FIXED CODE ###

import math
r = float(input())
v = math.pi*r*r
s = math.pi*r*2

print('%.7f %.7f'%(v,s))
from collections import deque
f_inf = float('inf')
H, W = map(int, input().split())
ch, cw = map(int, input().split())
ch, cw = ch-1, cw-1
dh, dw = map(int, input().split())
dh, dw = dh-1, dw-1
S = [list(input()) for _ in range(H)]
m = [[f_inf]*W for _ in range(H)]
m[ch][cw] = 0
que = deque([])
que.appendleft([ch,cw])
while que:
  h, w = que.popleft()
  for dh, dw in ((1,0), (-1,0), (0, 1), (0, -1)):
    next_h, next_w = h + dh, w + dw
    if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w]:
          m[next_h][next_w] = m[h][w] # 移動Aで行けるところにmの値を合わせる
          que.appendleft([next_h,next_w])
  for dh in range(-2, 3):
    for dw in range(-2, 3): # 移動Bで行ける範囲
      next_h, next_w = h + dh, w + dw
      if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w] + 1: # h,wから移動Aですでに行けているところは更新されない
          m[next_h][next_w] = m[h][w] + 1 
          que.append([next_h, next_w]) # appendleftではなくappend 優先順位が後
print(m[dh][dw] if m[dh][dw] != f_inf else -1)

### FIXED CODE ###

from collections import deque
f_inf = float('inf')
H, W = map(int, input().split())
sh, sw = map(int, input().split())
sh, sw = sh-1, sw-1
eh, ew = map(int, input().split())
eh, ew = eh-1, ew-1
S = [list(input()) for _ in range(H)]
m = [[f_inf]*W for _ in range(H)]
m[sh][sw] = 0
que = deque([])
que.appendleft([sh,sw])
while que:
  h, w = que.popleft()
  for dh, dw in ((1,0), (-1,0), (0, 1), (0, -1)):
    next_h, next_w = h + dh, w + dw
    if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w]:
          m[next_h][next_w] = m[h][w] # 移動Aで行けるところにmの値を合わせる
          que.appendleft([next_h,next_w])
  for dh in range(-2, 3):
    for dw in range(-2, 3): # 移動Bで行ける範囲
      next_h, next_w = h + dh, w + dw
      if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w] + 1: # h,wから移動Aですでに行けているところは更新されない
          m[next_h][next_w] = m[h][w] + 1 
          que.append([next_h, next_w]) # appendleftではなくappend 優先順位が後
print(m[eh][ew] if m[eh][ew] != f_inf else -1)
x=int(input())
l=[]
for s in range(1,x):
  for t in range(2,x):
    if s**t<x:
      l.append(s**t)
    if s**t>x:
      break
print(max(l))

### FIXED CODE ###

x=int(input())
l=[]
for i in range(1,40):
  for j in range(2,40):
    if i**j<=x:
      l.append(i**j)
print(max(l))
N,Q=map(int,input().split())
G=[[] for _ in range(N+1)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a].append(b)
#このような木に関する問題では、木の代わりに 1−2−3−...−N という直線的なグラフを考えると助け になることがある
cnt=[0]*(N+1)
from collections import deque
for _ in range(N-1):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p,x=map(int,input().split())
    cnt[p]+=x

queue=deque([1])
visited={1}
while queue:
    tmp=queue.popleft()
    visited.add(tmp)
    for t in G[tmp]:
        if t in visited:
            pass
        else:
            queue.append(t)
            cnt[t]+=cnt[tmp]

print(*cnt[1:])

### FIXED CODE ###

N,Q=map(int,input().split())
G=[[] for _ in range(N+1)]
#このような木に関する問題では、木の代わりに 1−2−3−...−N という直線的なグラフを考えると助け になることがある
cnt=[0]*(N+1)
from collections import deque
for _ in range(N-1):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p,x=map(int,input().split())
    cnt[p]+=x

queue=deque([1])
visited={1}
while queue:
    tmp=queue.popleft()
    visited.add(tmp)
    for t in G[tmp]:
        if t in visited:
            pass
        else:
            queue.append(t)
            cnt[t]+=cnt[tmp]

print(*cnt[1:])
N = int(input())
A = [a for a in map(int, input().split())]

#N個のボールに対して、書かれている数字は1~Nまで

dic1 = {}
for i in range(N):
    dic1[i] = 0

#dicにkeyとなる数字の個数を入れていく
for i in A:
    if i in dic1.keys():
        dic1[i] += 1

dic2 = {}
#組み合わせの数を入れる   
for i in range(N):
    dic2[i] = dic1[i]*(dic1[i]-1)/2

ans1 = 0
for i in range(N):
    ans1 += dic2[i]

for i in range(N):
    ans2 = ans1
    ans2 -= dic2[A[i]] #組み合わせの数を引く
    ans2 += (dic1[A[i]]-1)*(dic1[A[i]]-2)/2
    print(ans2)

### FIXED CODE ###

N = int(input())
A = [a for a in map(int, input().split())]

#N個のボールに対して、書かれている数字は1~Nまで

dic1 = {}
for i in range(N):
    dic1[i+1] = 0

#dicにkeyとなる数字の個数を入れていく
for i in range(N):
    if A[i] in dic1.keys():
        dic1[A[i]] += 1

dic2 = {}
#組み合わせの数を入れる   
for i in range(N):
    dic2[i+1] = dic1[i+1]*(dic1[i+1]-1)/2

ans1 = 0
for i in range(N):
    ans1 += dic2[i+1]

for i in range(N):
    ans2 = ans1
    ans2 -= dic2[A[i]] #組み合わせの数を引く
    ans2 += (dic1[A[i]]-1)*(dic1[A[i]]-2)/2 #新たな組み合わせの数を足す
    print(int(ans2))
# coding: UTF-8
	# ???????????´??° x ???????????????????????????????????????????????????????????°?????????????????????????????????

	data_set = []
	while True:
		n = input()
		if n == 0:
			break
		data_set.append(n)

	case = 1
	for n in data_set:
		print "Case %d: %d" %(case, n)
		case +=	1

### FIXED CODE ###

# coding: UTF-8
# ???????????´??° x ???????????????????????????????????????????????????????????°?????????????????????????????????

data_set = []
while True:
	n = input()
	if n == 0:
		break
	data_set.append(n)

case = 1
for n in data_set:
	print "Case %d: %d" %(case, n)
	case +=	1
n=raw_input()
a=[]
for i in range(n):
   a.append(int(raw_input()))
print "%d %d %d" %(min(a), max(a), sum(a))

### FIXED CODE ###

n=input()
a=map(int,raw_input().split())
print "%d %d %d" % (min(a), max(a), sum(a))
from collections import deque

n = int(input())

dlist = deque()

for i in range(n):
    arr = input().split()
    cmd = ''
    key = 0
    cmd = arr[0]
    if len(arr) > 1:
        key = arr[1]
    if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            #
    elif cmd == 'deleteFirst':
        dlist.pop()
    elif cmd == 'deleteLast':
        dlist.popleft()

print(' '.join(dlist))



### FIXED CODE ###

from collections import deque

n = int(input())

dlist = deque()

for i in range(n):
    arr = input().split()
    cmd = ''
    key = 0
    cmd = arr[0]
    if len(arr) > 1:
        key = arr[1]
    if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
    elif cmd == 'deleteFirst':
        dlist.popleft()
    elif cmd == 'deleteLast':
        dlist.pop()

print(' '.join(dlist))
import math
A, B, K = map(int, input().split())
A_B_gcd = math.gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
print(yakusuu_arr[K-1])

### FIXED CODE ###

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while True:
            if x % y != 0:
                z = x % y
                x = y
                y = z
            else:
                break
        return z
A, B, K = map(int, input().split())
A_B_gcd = gcd(A, B)
yakusuu_arr = []
for i in range(1, A_B_gcd+1):
    if A_B_gcd % i == 0:
        yakusuu_arr.append(i)
yakusuu_arr.sort(reverse=True)
print(yakusuu_arr[K-1])
import sys
read=sys.stdin.read

n,*a=map(int,read().split())
l=[0]*(max(a)+1)
for x in a:
  l[x]^=1
print(sum(l))

### FIXED CODE ###

import sys
from collections import Counter
read=sys.stdin.read

n,*a=map(int,read().split())
x=Counter(a)
print(sum(list(map(lambda n:n%2, list(x.values())))))
a,b,c = map(int, raw_input().split())
n = [a,b,c]
x = n.sort()
for i in x:
    print i,

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
n = [a,b,c]
n.sort()
for i in n:
    print i,
a = int(input())
print(a + a**2 + a***a)

### FIXED CODE ###

a = int(input())
print(a + a**2 + a**3)
from collections import deque
s = deque()
n = int(input())
initial = "left"
for i in range(n):
    order = list(input().split())
    if len(order) == 3:
        if initial == "left":
            if int(order[1]) == 1:
                s.appendleft(order[2])
            else:
                s.append(order[2])
        else:
            if int(order[1]) == 1:
                s.append(order[2])
            else:
                s.appendleft(order[2])
    else:
        initial = "right"
    
if initial == "left":
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

from collections import deque
s = deque(input())
n = int(input())
initial = True
for i in range(n):
    order = list(input().split())
    if len(order) == 3:
        if initial:
            if int(order[1]) == 1:
                s.appendleft(order[2])
            else:
                s.append(order[2])
        else:
            if int(order[1]) == 1:
                s.append(order[2])
            else:
                s.appendleft(order[2])
    else:
        initial = not initial
    
if initial:
    print(''.join(s))
else:
    print(''.join(s)[::-1])
a =list( map(int, input.split()) )
a = sum(a)
if(a>=22):
  print("bust")
else:
  print("win")


### FIXED CODE ###

a =list( map(int, input().split()) )
a = sum(a)
if(a>=22):
  print("bust")
else:
  print("win")
x, op, y = map(string, input().split())
x = int(x)
y = int(y)
while not (x == 0 and y == 0 and op == "?") :
 if op == "+" :
  print(x + y)
 elif op == "-":
  print(x - y)
 elif op == "*":
  print(x * y)
 elif op == "/":
  print(x / y)

### FIXED CODE ###

x, op, y = input().split()
x = int(x)
y = int(y)
while op != "?" :
 if op == "+" :
  print(x + y)
 elif op == "-":
  print(x - y)
 elif op == "*":
  print(x * y)
 elif op == "/":
  print(x // y)
 x, op, y = input().split()
 x = int(x)
 y = int(y)
n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0

def enqueue(x):
    global tail
    Q[tail] = ???
    tail = (tail + 1) % MAX

def dequeue():
    global head
    x,t = Q[head]
    head = (head + 1) %MAX
    return [x,t]
for i in range(n):
    P = input().split()
    enqueue([P[0], int(P[1])])

elaps = 0
while head != tail:
    u,t = dequeue()
    c = min(q, t)
    t -= c
    elaps += c
    if t > 0:
        enqueue([u,t])
    else:
        print(u + " " + str(elaps))

### FIXED CODE ###

n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0

def enqueue(u, t):
    global tail
    Q[tail] = [u, t]
    tail = (tail + 1) % MAX

def dequeue():
    global head
    x,t = Q[head]
    head = (head + 1) %MAX
    return [x,t]
for i in range(n):
    P = list(input().split())
    enqueue(P[0], int(P[1]))

elaps = 0
while head != tail:
    u,t = dequeue()
    c = min(q, t)
    t -= c
    elaps += c
    if t > 0:
        enqueue(u,t)
    else:
        print(u + " " + str(elaps))
N = int(input())
print('ABD{%03d}'.format(N-1000)) if N>=1000 else print('ABC{%03d}',format(N))

### FIXED CODE ###

print('ABD') if int(input())>=1000 else print('ABC')
lst=input().split()
x_1=lst[0]
y_1=lst[1]
x_2=lst[2]
y_2=lst[3]
dis=((x_1-y_1)**2+(x_2-y_2)**2)**(1/2)
print(dis)


### FIXED CODE ###

lst=input().split()
lst=list(map(lambda i:float(i),lst))
x_1=lst[0]
x_2=lst[1]
y_1=lst[2]
y_2=lst[3]
dis=((x_1-y_1)**2+(x_2-y_2)**2)**(1/2)
print(dis)
x = list(map(int,input().split()))
for i in range(len(x)):
  if x[i] = 0:
    print(i)
    break

### FIXED CODE ###

x = list(map(int,input().split()))
for i in range(len(x)):
  if x[i] == 0:
    print(i+1)
    break
N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 0

if  0 in x:
    K-=1
    x.pop(0)

if K > 0:
    ansp,ansm,anso,border = 1e8,1e8,1e8,0
    while border < N and x[border] < 0:
        border += 1
    
    if N - border >= K: ansp = x[border+K-1]
    if border >= K: ansm = -x[border-K+1]
    
    if border!=0 and border!=N-1:
        xn = sorted(x,key = lambda x: abs(x))[:K]
        if xn[-1] > 0:
            pmax,i = xn[-1],2
            while xn[-i] > 0:
                i += 1
            mmax = xn[-i]
            anso = pmax - 2*mmax
        else:
            mmax,i = xn[-1],2
            while xn[-i] < 0:
                i += 1
            pmax = xn[-i]
            anso = 2*pmax - mmax
    
    ans = min(ansp,ansm,anso)

print(ans)
        

### FIXED CODE ###

N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 1e10

for i in range(N-K+1):
    l,r = x[i],x[i+K-1]
    if l < 0 and r <= 0: temp = -l
    elif l >= 0 and r > 0:   temp = r
    else:
        if -l < r:    temp = 2*(-l) + r
        else:    temp = -l + 2*r  
    
    if ans > temp:  ans = temp

print(ans)
import functools

n = input()
while(n):
    list = []
    bottom_record = [0]*(n+1)

    for i in range(0, n):
        l = map(int, raw_input().split())
        l.append(functools.reduce(lambda x, y: x + y, l))
        bottom_record = [x + y for(x,y) in zip(bottom_record, l)]
        print(' '.join(map(str, l))) 
    print(' '.join(map(str, bottom_record)))
    n = input()

### FIXED CODE ###

n = int(input())
while(n):
    bottom_record = [0]*(n+1)

    for i in range(0, n):
        l = list(map(int, input().split()))
        l.append(sum(l))
        bottom_record = [x + y for(x,y) in zip(bottom_record, l)]
        print(''.join(map('{0:5d}'.format, l))) 
    print(''.join(map('{0:5d}'.format, bottom_record)))
    n = int(input())
n,k=map(int,input().split())
print=(len.list[x for x in int(input()) if k<x])


### FIXED CODE ###

n, k = map(int, input().split())
lst = [int(i) for i in input().split()]
print(len([j for j in lst if j >= k]))
N, A, B = map(int, innput().split())
print(min([N*A,B]))

### FIXED CODE ###

N, A, B = map(int, input().split())
print(min([N*A,B]))
a = list(list(map(int , input().split())) for l in range(3))
n = int(input())

for i in range(input()):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

### FIXED CODE ###

a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1
    sys.stdout.write(' ')

### FIXED CODE ###

import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')
A, B = map(int, input().split())

import math


def dv(x1, x2):
    ret = []
    v = int(math.sqrt(min(x1, x2))) + 1

    check = [0] * (v + 1)

    for n in range(2, v):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 1
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret


cf = [1] + dv(A, B)
print(len(cf))


### FIXED CODE ###

N = int(input())

x = N % 2

if x == 0:
    print(1/2)
else:
    y = N // 2 + 1
    print(y / N)
N,A = map(int,input().split())
X = [0]+list(map(int,input().split()))

sumX = sum(X)
dp = [[[0 for _ in range(sumX+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(0,i+1):
        for k in range(sum(X)+1):
            if j==0 and k==0:
                dp[i][j][k] = 1
            elif k < X[i]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]]

if max(X) < A:
    print(0)
else:
    Ans = 0
    for i in range(1,N+1):
        Ans += dp[N][i][A*i]
    print(Ans)

### FIXED CODE ###

N,A = map(int,input().split())
X = [0]+list(map(int,input().split()))

dp = [[[0 for _ in range(2500+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(0,i+1):
        for k in range(2500+1):
            if j==0 and k==0:
                dp[i][j][k] = 1
            elif k < X[i]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]]

if max(X) < A:
    print(0)
else:
    Ans = 0
    for i in range(1,N+1):
        Ans += dp[N][i][A*i]
    print(Ans)
# 2019 12/01
# A November 30

M1, D1 = map(int, input())
M2, D2 = map(int, input())

if int(D2) == 1:
    print(1)
else:
    print(0)

### FIXED CODE ###

# 2019 12/01
# A November 30

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if int(D2) == 1:
    print(1)
else:
    print(0)
import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)


for _ in range(int(input())):
    n = int(input())
    #a = list(map(int, input().split()))
    #= map(int, input().split())
    if n>=30:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)


n = int(input())
#a = list(map(int, input().split()))
#= map(int, input().split())
if n>=30:
    print('Yes')
else:
    print('No')
a, b, c = map(int, input().split())
print('%s', 'Yes' if a < b && b < c else 'No')


### FIXED CODE ###

a, b, c = map(int, input().split())
print('%s' % 'Yes' if a < b and b < c else 'No')
a = list(map(int, input().split()))
strs=[]
for i in range(a[0]):
	strs.append(input())
print("".join(sorted(strs)))


### FIXED CODE ###

abc = list(map(int,input().split()))
print("YES" if sum(abc) == 17 and abc.count(5) else "NO")
a,b,c=eval('int(input())'*3)
print((a+b)*h//2)

### FIXED CODE ###

a,b,c,d=eval('['+'int(input()),'*3+'0]');print((a+b)*c//2)
def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	for _ in range(N):
		icicles.append(int(input().strip()))
	return icicles, N, L

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

icicles, N, L = loadIcicle()
diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i] == -1]
for i in peakX:
	time[i] = L - icicles[i]

	posL, posR = i, i	
	while True:
		posL -= 1
		if posL < 0: break
		if not isLocalMinL:
			left = 0 if posL-1 < 0 else time[posL-1]
			time[posL] = (L-icicles[posL]) + max(left, time[posL+1])
			if diff_2times[posL] == 1: break
	while True:
		posR += 1
		if posR > N-1: break
		if not isLocalMinR:
			right = 0 if posR+1 > N-1 else time[posR+1]
			time[posR] = (L-icicles[posR]) + max(time[posR-1], right)
			if diff_2times[posR] == 1: break

print(max(time))

### FIXED CODE ###

def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

icicles, N, L = loadIcicle()
diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i]==-1]
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL, posR = i, i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		if posL < 0:
			isLocalMinL = True
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])

			if diff_2times[posL] == 1:
				isLocalMinL = True

		posR += 1
		if posR >= N:
			isLocalMinR = True
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])

			if diff_2times[posR] == 1:
				isLocalMinR = True

print(max(time))
X,Y=list(map(int,input().split()))

import sys
if (2*Y-X)%3!=0 or (2*X-Y)%3!=0:
  print(0)
  sys.exit()

x=(2*Y-X)//3
y=(2*X-Y)//3
#(x+y)Cxを求める
fac=[0 for i in range(x+y+1)]
inv=[0 for i in range(x+y+1)]
finv=[0 for i in range(x+y+1)]
#初期条件
p=1000000007
fac[0]=fac[1]=1
inv[1]=1
finv[0]=finv[1]=1
#テーブルの作成
for i in range(2,x+y+1):
  fac[i]=fac[i-1]*i%p
  #p=(p//a)*a+(p%a) a^(-1)=-(p//a)*(p%a)^(-1)
  inv[i]=(-(p//i)*inv[p%i])%p
  finv[i]=finv[i-1]*inv[i]%p
#求める
print(x+y)
print(x)
print(y)

print((fac[x+y]*finv[x]%p)*finv[y]%p)




### FIXED CODE ###

X,Y=list(map(int,input().split()))

import sys
if (2*Y-X)%3!=0 or (2*X-Y)%3!=0:
  print(0)
  sys.exit()
if (2*Y-X)<0 or (2*X-Y)<0:
  print(0)
  sys.exit()
x=(2*Y-X)//3
y=(2*X-Y)//3
#(x+y)Cxを求める
fac=[0 for i in range(x+y+1)]
inv=[0 for i in range(x+y+1)]
finv=[0 for i in range(x+y+1)]
#初期条件
p=1000000007
fac[0]=fac[1]=1
inv[1]=1
finv[0]=finv[1]=1
#テーブルの作成
for i in range(2,x+y+1):
  fac[i]=fac[i-1]*i%p
  #p=(p//a)*a+(p%a) a^(-1)=-(p//a)*(p%a)^(-1)
  inv[i]=(-(p//i)*inv[p%i])%p
  finv[i]=finv[i-1]*inv[i]%p
#求める

print((fac[x+y]*finv[x]%p)*finv[y]%p)
import numpy
nums1 = []
for i in range(2):
    nums = [int(e) for e in input().split()]
    nums1.append(nums)

max = numpy.max(nums1[1])
min = numpy.min(nums1[1])
sum = numpy.sum(nums1[1])

print(max, min, sum)


### FIXED CODE ###


nums1 = []
sum = 0
for i in range(2):
    nums = [int(e) for e in input().split()]
    nums1.append(nums)

max = nums1[1][0]
min = nums1[1][0]
sum = 0

for i in range(len(nums1[1])):
    if nums1[1][i]>max:
        max = nums1[1][i]
    if nums1[1][i]<min:
        min = nums1[1][i]
    sum = sum + nums1[1][i]
    
print(min, max, sum)
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()
for i in b[a[1]]:
  c=0
  c+=b[i]
  return c
print(c)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))