peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def gcd(a,b):
    if a == 0 or b == 0:
        return max(a,b)
    return a if b==0 else gcd(b,a%b)
N = int(input())
A = list(map(int,input().split()))
rA = A[::-1]

LEFT = [0]
g = A[0]
for i in range(N):
    g = gcd(g,A[i])
    LEFT.append(g)


RIGHT = [0]
g = rA[0]
for i in range(N):
    g = gcd(g,rA[i])
    RIGHT.append(g)


ans = 0
for i in range(1,N+1):
    ans = max(ans,gcd(LEFT[i-1],RIGHT[N-i]))
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

d1 = b - a
d2 = c - b

if (d1 == d2):
    print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
N, A = [int(input()) for _ in range(2)]

if N >= A:
  if (N - A) % 500 == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')
# Judge status: Accepted
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        # import math
        import fractions
        return (x * y) // fractions.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()
# Judge status: Wrong Answer
ABC = list(map(int, input().split()))

mini = float('inf')

if ABC[0]%2 == ABC[1]%2 == ABC[2]%2 == 0:
    print(0)
else:
    for i in range(3):
        if ABC[i]%2 == 1:
            calc = 1
            for j in range(3):
                if i != j:
                    calc *= ABC[j]
            if calc < mini:
                mini = calc
    print(calc)
# Judge status: Accepted
a, b = map(int, input().split())

print((a+b)%24)
# Judge status: Accepted
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    if n >= 30:
        print('Yes')
    else:
        print('No')
    
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = input()
k = len(n)
a = 9 * (k - 1)
b = 0
for i in range(k):
  b += int(n[i])
c = 0
m = ''
if k > 2 and n[-2] != '0':
  m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9'
elif k > 2 and n[-2] == '0':
  m = str(int(n) - (int(n[-1]) + 1))
for i in range(len(m)):
  c += int(m[i])
ans = max(a, b, c)
print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
s=0
for i in range(N-1):
  if A[i]>A[i+1]:
    s+=A[i]-A[i+1]
print(s)
# Judge status: Accepted
S = input()
a = 0
b = 0
if (S[0] == '0' and S[1] != '0') or (S[0] == '1' and (S[1] == '0' or S[1] == '1' or S[1] == '2')):
  a = 1
if (S[2] == '0' and S[3] != '0') or (S[2] == '1' and (S[3] == '0' or S[3] == '1' or S[3] == '2')):
  b = 1
if a == 1 and b == 1:
  print("AMBIGUOUS")
elif a == 1:
  print("MMYY")
elif b == 1:
  print("YYMM")
else:
  print("NA")
# Judge status: Wrong Answer
n=int(input())
a=[]
[a.append(int(input())) for _ in range(n)]
b = sorted(a)
if len(set(b))==1:
  best=better=b[-1]
else:
  best=list(set(b))[-1]
  better=list(set(b))[-2]
for i in range(n):
  if a[i] == best:
    print(better)
  else:
    print(best)
# Judge status: Accepted
x = int(input())

# 6 5 6 5 ...
# ex) 23
# (x // 11 * 2) + 1
# ex) 29
# (x // 11 * 2) + 2

p, m = divmod(x, 11)
p *= 2

if m > 6:
    print(p + 2)
elif m == 0:
    print(p)
else:
    print(p + 1)
# Judge status: Accepted
N, K = map(int,input().split())
ans = 0
while(K ** ans <= N):
    ans += 1
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
s = list(input())[: -1]
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + (s[i] == "#")
res = float("inf")
for i in range(N + 1):
  r = cs[-1] - cs[i]
  l = i - cs[i]
  res = min(res, N - i - r + i - l)
print(res)
# Judge status: Accepted
a, b, c = map(int, input().split())
if c-a-b < 0:
    print("No")
elif 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int, input().split())

if a <= b:
  print(a)
else:
  print(a-1)
# Judge status: Accepted
n  = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

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

print(sum)
# Judge status: Accepted
def main():
  from collections import deque
  n,m=map(int,input().split())
  ab=[[] for _ in range(n+1)]
  for _ in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
  
  l=deque([1])
  ans=[-1]*n
  while l:
    x=l.popleft()
    for i in ab[x]:
      if ans[i-1]==-1:
        ans[i-1]=x
        l.append(i)
  print('Yes')
  for i in ans[1:]:
    print(i) 
    
if __name__=='__main__':
  main()
# Judge status: Accepted
# coding: utf-8
# Your code here!

s = list(input())

t = []

for i in range(len(s)):
    if s[i] == '0':
        t.append('0')
    elif s[i] == '1':
        t.append('1')
    else:
        if len(t) != 0:
            del t[-1]

print(''.join(t))
# Judge status: Accepted
x, y = map(int, input().split())

print(int(x+y/2))
# Judge status: Accepted
s = input()
cnt = 0
for i in range(len(s)//2):
    if s[i] != s[len(s)-1-i]:
        cnt += 1
print(cnt)
# Judge status: Accepted
# 138a https://atcoder.jp/contests/abc138/tasks/abc138_a

# 入力
a = int(input())
s = input()

# 処理
if a < 2800 or a >= 5000:
    answer = '制約値外です'
elif a >= 3200:
    answer = s
elif a < 3200:
    answer ='red'

# 出力
print(answer)
# Judge status: Accepted
a,b = map(int, input().split())

if a % 3 == 0 or b %3 == 0 or (a+b)%3 == 0:
  print("Possible")
else:
  print("Impossible")
# Judge status: Accepted
n=int(input());print(-(-n//2)*(n//2))
# Judge status: Accepted
N = int(input())
A = [int(_) for _ in input().split()]

ans = 0
for i, a in enumerate(A):
    if i % 2 == 0 and a % 2 == 1:
        ans += 1
print(ans)
# Judge status: Wrong Answer
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
p = 0

for ai in a:
  if p + ai > x:
    d = p + ai - x
    ans += d
    p = ai - d
    
print(ans)
# Judge status: Accepted
N,A,B=map(int,input().split())
S=input()
pass_a=1
pass_b=1
for x in S:
  if x=="a":
    if pass_a<=A+B:
      print("Yes")
      pass_a+=1
    else:
      print("No")
  elif x=="b":
    if pass_a<=A+B and pass_b<=B:
      print("Yes")
      pass_a+=1
      pass_b+=1
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
s = input()

ans = "Yes"

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "L":
            ans = "No"
    else:
        if s[i] == "R":
            ans = "No"

print(ans)
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[16]:


S = input()
T = input()


# In[20]:


mydict = {}
for i in range(len(S)):
    if S[i] in mydict:
        if T[i] != mydict[S[i]]:
            ans = "No"
            break
    else:
        mydict[S[i]] = T[i]
else:
    a = list(mydict.values())
    b = list(set(a))
    if len(b) != len(a):
        ans = "No"
    else:
        ans = "Yes"
print(ans)


# In[ ]:
# Judge status: Accepted
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
list_LR = [list(map(int, input().split())) for i in range(M)]
# print(list_LR)

L = 0
R = N
for i in range(M):
    L = max(L, list_LR[i][0])
    R = min(R, list_LR[i][1])
if L > R:
    print(0)
else:
    print(R-L+1)
# Judge status: Wrong Answer
h1,m1,h2,m2,k = map(int,input().split())

time = (h2 - h1) * 60 - (m2 - m1)
print(time - k)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    A=[0]*(n+1)
    for i in range(n):
        if s[i]=="<":
            A[i+1]=A[i]+1
    for i in range(n):
        if s[n-i-1]==">":
            A[n-i-1]=max(A[n-i-1],A[n-i]+1)
    print(sum(A))

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
import sys
n,x=map(int,input().split())
N=list(map(int,input().split()))
K=sorted(N,reverse=True)
if sum(K)<=x:
  print(n)
  sys.exit()
for i in range(1,n+1):
  if sum(K)-K[0]<=x:
    print(n-i)
    sys.exit()
  else:
    K.pop(0)
# Judge status: Wrong Answer
a = 2
variable = input(a + a*a + a*a*a)
print(variable)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]

a.sort()
print(sum(a[n-1::-2]) - sum(a[n-2::-2]))
# Judge status: Wrong Answer
N = int(input())
robot = [input().split() for i in range(N)]

le = [[int(i[0])-int(i[1]), int(i[0])+int(i[1])] for i in robot]
le.sort(key = lambda x:x[1])

ans = 0
floor = -10**5
for i in range(N):
    if floor <= le[i][0]:
        ans += 1
        floor = le[i][1]

print(ans)
# Judge status: Accepted
mod = 1000000007

def sum_(a, b):
    return int((a+b)*(b-a+1)/2)

def main():
    args = input().rstrip().split(' ')
    N, K = int(args[0]), int(args[1])
    
    Ans = 0
    for i in range(K, N+2):
        sum_b = sum_(0, i-1)
        sum_u = sum_(N-i+1, N)
        Ans += (sum_u-sum_b)+1
        Ans = Ans % mod
    print(Ans)
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

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

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

tx = 1
for a in A:
    tx = lcm(tx, a)

B = []
for a in A:
    B.append(tx // a)

for b in B:
    if b % 2 == 0:
        print(0)
        sys.exit()
ans = ((M // (tx//2)) + 1) // 2
print(ans)
# Judge status: Accepted
n =int(input())
ab = []

for i in range(n):
    a,b = map(int,input().split())
    ab.append([b,a])
ab.sort()
time = 0
ok = True
for i in range(n):
    a = ab[i][1]
    b = ab[i][0]
    if time + a > b:
        ok = False
        break
    time +=a
if ok :print('Yes')
else:print('No')
# Judge status: Accepted
N,M=map(int,input().split())
A=list(map(int,input().split()))
k=0
l=0
for i in range(N):
    k+=A[i]
for i in range(N):
    if ((A[i]/k)>=(1/(4*M))):
        l+=1
if l>=M:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
  _, *h=map(int, open(0).read().split())
  x=h[-1]
  for y in h[-2::-1]:
    if x<y-1:
      return 'No'
    x=y-(x<y)    
  return 'Yes'

if __name__ == '__main__':
  print(main())
# Judge status: Accepted
x = int(input())
a = (x // 11) * 2
b = 2 if x % 11 > 6 else 0 if x % 11 == 0 else 1

print(a + b)
# Judge status: Wrong Answer
import time
import itertools

N = int(input())
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

p = list(itertools.product(range(1,25),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

for n in range(1,N + 1):
    print(a.count(n))
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
su = 0
kinshi = ''
dashita = [''] * N
for i in range(len(T)):
  s = T[i]
  if i - K >= 0:
    if s == dashita[i - K]:    
      continue
  if s == 'r':
    su += P
  elif s == 's':
    su += R
  elif s == 'p':
    su += S
  dashita[i] = s
print(su)
# Judge status: Wrong Answer
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]

B=[0]*N
# from functools import lru_cache
# @lru_cache(maxsize=1000)
# def yapoos()
for i in A:
    if H[i[0]-1]>H[i[1]-1]:
        B[i[0]-1]=1
    elif H[i[0]-1]<H[i[1]-1]:
        B[i[1]-1]=1
print(B.count(0))
# Judge status: Accepted
N, W = [int(i) for i in input().split()]
weight, value = [0] * (N + 1), [0] * (N + 1)
for i in range(1, N + 1):
    weight[i], value[i] = [int(i) for i in input().split()]
#%%
dp = [[0] * (W + 1) for _ in range(N + 1)]

#%%
for i in range(1, N + 1):
    for j in range(1, W + 1):
        if weight[i] <= j:
            dp[i][j] = max(value[i] + dp[i - 1][j - weight[i]], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]
print(int(dp[-1][-1]))
# Judge status: Wrong Answer
a,b,n = (int(x) for x in input().split())
print(n-(a-b)+1)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
p = sorted(sorted([int(x) for x in input().split()])[-X:] + sorted([int(x) for x in input().split()])[-Y:] + [int(x) for x in input().split()])

print(sum(p[-X-Y:]))
# Judge status: Accepted
n = int(input())
L = list(map(int,input().split()))
maxL = max(L)
sum = 0
flag = True
for l in L:
  if l == maxL and flag:
    flag = False
  else:
    sum += l
if maxL < sum:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, T = map(int, input().split())
List = []
List2 = []
min = float('inf')

for i in range(N):
    M, B = map(int, input().split())
    List.append([M,B])
    M, B = 0, 0

for k in range(N):
    if int(List[k][1]) <= T:
        List2.append(List[k])

for n in range(len(List2)):
    if List2[n][0] <= min:
        min = List2[n][0]

if min > T:
    print('TLE')
else:
    print(min)
# Judge status: Accepted
S = input()
T = input()

for i in range(len(S) - len(T),-1,-1):
  for j in range(len(T)):
    if S[j + i] != "?" and S[j + i] != T[j]:
      break
  else:
    S = S.replace("?","a")
    print(S[:i] + T + S[i + len(T):])
    break
else:
  print("UNRESTORABLE")
# Judge status: Wrong Answer
n=int(input())
l1=2
l2=1
for i in range(n-2):
  if i%2==0:
    l1=l1+l2
  else:
    l2=l1+l2
print(l1+l2)
# Judge status: Wrong Answer
n,m=map(int,input().split())
r=[0]*n
w=[1]*n
r[0]=1
w[0]=0
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if r[x] and w[x]==0:
        r[x]=0
        r[y]=1
    elif r[x]:
        w[x]-=1
        r[y]=1
    else:
      w[x]-=1
      w[y]+=1
print(sum(r))
# Judge status: Accepted
n,a,b = map(int,input().split())
inf = 10**9 +7
ans = pow(2,n,inf)-1
def conbi(n,k):
  if n-k < k:
    k = n-k
  x = 1
  y = 1
  for i in range(k):
    x *= n-i
    x = x%inf
    y *= i+1
    y = y%inf
  ans = x* pow(y,inf-2,inf)%inf
  return ans
ans  -= conbi(n,a) + conbi(n,b)
ans = ans%inf
print(ans)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    
    tmp_8 = int(a / 0.08)
    tmp_10 = int(b / 0.1)

    check_10 = int(tmp_8*0.1)
    check_8 = int(tmp_10*0.1)

    if check_8 != check_10:
        print(-1)
    else:
        print(tmp_8)




if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if A - B == 0:
    print('YES')
elif V <= W:
    print('NO')
elif V == 0:
    print('NO')
else:
    print('YES' if abs(A-B)//abs(V-W) <= T else 'NO')
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)
 
a,b,c = sorted(map(int,readline().split()))
print (10 * c  + b + a)
# Judge status: Accepted
import sys
input = sys.stdin.readline

weather = {"Sunny":"Cloudy", "Cloudy":"Rainy", "Rainy":"Sunny"}

print(weather[input().rstrip()])
# Judge status: Accepted
N, M = map(int, input().split())
sc = []
for _ in range(M):
    s, c = map(int, input().split())
    sc.append((s - 1, str(c)))

ans = -1
for i in map(str, range(10 ** (N - 1) if N > 1 else 0, 10 ** N)):
    for s, c in sc:
        if i[s] != c:
            break
    else:
        ans = i
        break
print(ans)
# Judge status: Accepted
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  for j in range(i+1,n):
    index=bisect.bisect_left(l,l[i]+l[j])
    ans+=index-j-1
print(ans)
# Judge status: Accepted
n = int(input())

sum_div = sum(range(1, n+1))
for i in range(2, n+1):
    sum_div += sum(range(i, n+1, i))
print(sum_div)
# Judge status: Accepted
a,b,x = map(int,input().split())

import math

d = x/(a**2)

c = b-d
e = c*2
if e<=b:
    f = (e**2+a**2)**(1/2)
    g = (f**2+a**2-e**2)/(2*f*a)
    print(math.degrees(math.acos(g)))
else:
    e = 2*x/(a*b)
    #print(e)
    a = b
    f = (e**2+a**2)**(1/2)
    g = (f**2+a**2-e**2)/(2*f*a)
    print(90-(math.degrees(math.acos(g))))
# Judge status: Accepted
from collections import Counter


N = int(input())
A = sorted(map(int, input().split()))

sifter = {i: True for i in range(1, A[N - 1] + 1)}
counter = Counter(A)
ans = 0
for A_i in A:
  if sifter[A_i]:
    if counter[A_i] == 1:
      ans += 1
    for i in range(A_i, A[N - 1] + 1, A_i):
      sifter[i] = False
      
print(ans)
# Judge status: Accepted
import math
n=int(input())
l=[int(input()) for i in range(5)]
ans=math.ceil(n/min(l))+4
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())

if c-a-b > 0 and 4 * a * b < (c-a-b) ** 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
w,h,x,y = map(int,input().split())
area = w*h/2
if x == w/2 and y == h/2:
    print(area, 1)
else:
    print(area,0)
# Judge status: Accepted
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import itertools

N = int(readline())
P = tuple(map(int, readline().split()))
Q = tuple(map(int, readline().split()))

per = itertools.permutations(range(1, N+1))
for i, seq in enumerate(per):
    if seq == P:
        p_index = i + 1
    if seq == Q:
        q_index = i + 1

ans = abs(p_index - q_index)
print(ans)
# Judge status: Accepted
import math

h,a = (int(x) for x in input().split())
print(math.ceil(h/a))
# Judge status: Wrong Answer
x,y,z = map(int, input().split())
print(y,z,x)
# Judge status: Wrong Answer
from collections import deque

n,m=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

dist=[-1 for i in range(n)]
dist[0]=0

dq=deque()
dq.append(0)

while dq:
  x=dq.popleft()

  if x==n-1:
    if dist[x]==2:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

  for i in tree[x]:
    if dist[i]==-1:
      dist[i]=dist[x]+1
      dq.append(i)
# Judge status: Accepted
import numpy as np
n,m = list(map(int, input().split()))
x = sorted(list(map(int, input().split())))
x = np.array(x)
diff = sorted(x[1:]-x[:-1])[::-1]
print(sum(diff[n-1:]))
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a % 2 != b % 2:
	print('IMPOSSIBLE')
else:
	print((a + b) / 2)
# Judge status: Wrong Answer
A, B, T = map(int, input().split())
tc = 0
n = 0
cnt = 0

if A > T:
    pass
else:
    while tc <= T:
        n += B
        cnt += 1
        tc += cnt*A

print(n)
# Judge status: Accepted
A, B = map(int, input().split())
ans = 0
now = 1
while True :
    if now >= B :
        break
    now = now + A - 1
    ans += 1
print(ans)
# Judge status: Wrong Answer
from math import sqrt
n=int(input())
def make_divisors(n):
	lower_divisors , upper_divisors = [], []
	i = 1
	while i*i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n//i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
l=make_divisors(n)
if len(l)%2==0:
	print((l[len(l)//2]+l[(len(l)//2)-1])-2)
elif len(l)%2==1:
	print((sqrt(n)*2)-2)
# Judge status: Accepted
W,H,N = map(int, input().split())
minX = 0
maxX = W
minY = 0
maxY = H

for i in range(N):
  x,y,a = map(int, input().split())
  if a==1:
    minX = max(minX,x)
  elif a==2:
    maxX = min(maxX,x)
  elif a==3:
    minY = max(minY,y)
  elif a==4:
    maxY = min(maxY,y)

#print(minX,maxX,minY,maxY)
    
if minX >= maxX or minY >= maxY:
  print(0)
else:
  print((maxX - minX)*(maxY - minY))
# Judge status: Accepted
N, A, B = map(lambda x: int(x), input().split(" "))

if A == 0:
    print(0)
else:
    count = N // (A+B)
    result = count*A
    if (N-(count*(A+B))) >= A:
        result += A
    else:
        result += (N-(count*(A+B)))

    print(result)
# Judge status: Accepted
S = input()
T = input()
sum = 0
for i in range(len(S)):
  if S[i-1] != T[i-1]:
    sum = sum + 1
print(sum)
# Judge status: Wrong Answer
n, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    if A[i-1]+A[i] <= x:
        continue
    eat = A[i-1]+A[i] - x
    ans += eat
    A[i] = A[i]-eat

print(ans)
# Judge status: Accepted
#coding:utf-8
x, y = map(int, input().split())
def func(a):
    if a<0:
        return 1e+10
    else:
        return a
ls = [func(y-x),func(y+x)+1,func(-y-x)+1,func(-y+x)+2]
print (min(ls))
# Judge status: Accepted
N,K = map(int,input().split())
conv =""

def ten_to_K(N,K,conv):
  if N // K == 0:
    conv += str(N % K)
    return conv
  else:
    N = N // K
    conv += str(N % K)
    return ten_to_K(N,K,conv)

ans = ten_to_K(N,K,conv)
print(len(ans))
# Judge status: Wrong Answer
N, C, K = map(int, input().split())
T = [0]*N
cnt = 0
bus = 0
for i in range(N):
    T[i] = int(input())
T.sort()
    
tmp = T[0]+K
for i in range(N):
    if(T[i] <= tmp):
        cnt += 1
        if(cnt == C):
            bus += 1
            tmp = T[min(i+1, N-1)]+K
            cnt = 0
    else:
        bus += 2
        tmp = T[i]+K
        cnt = 0
print(bus)
# Judge status: Wrong Answer
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
for k in range(y):
    print("U")
for k in range(x+1):
    print("R")
for k in range(y+1):
    print("D")
for k in range(x+1):
    print("L")
print("U")
print("L")
for k in range(y+1):
    print("U")
for k in range(x+1):
    print("R")
for k in range(y+1):
    print("D")
print("L")
# Judge status: Wrong Answer
n,k = map(int, input().split())

digits = 0
while n:
  digits += 1
  n//=10
  
print(digits)
# Judge status: Wrong Answer
# WIP
C11, C12, C13 = map(int, input().split())
C21, C22, C23 = map(int, input().split())
C31, C32, C33 = map(int, input().split())

# Strategy:
# 3(a1+a2+a3+b1+b2+b3) = Σ_i Σ_j C_i_j
# sum of all C_i,j must be a mltiple of 3

sum_C = C11 + C12 + C13 + C21 + C22 + C23 + C31 + C32 + C33

if sum_C % 3 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
p = [int(x) for x in input().split()]
x=0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
        x+=1
print(x)
# Judge status: Accepted
N,K = map(int,input().split())
MOD = 10**9+7
res = 0
curmin,curmax = 0, N
mini,maxi = 1, N-1
for i in range(1,N+2):
  if i == N+1:
    # print(1)
    res += 1
  else:
    if i >= K:
      # print(curmin,curmax)
      res = (res + curmax - curmin + 1) % MOD
    curmin += mini
    curmax += maxi
    mini += 1
    maxi -= 1

print(res % MOD)
# Judge status: Wrong Answer
temp_list = [int(input()) for _ in range(6)]
n = temp_list.pop(0)
print(5 + n // min(temp_list))
# Judge status: Accepted
#n = int(input())
d,n = list(map(int,input().split()))

if n < 100:
	print(n*(100**d))
else:
  	print((n+1)*(100**d))
# Judge status: Accepted
from fractions import gcd
import sys
input = sys.stdin.readline
def lcm(a,b):
    return a*b // gcd(a,b)

def main():
    N = int(input())
    A = list(map(int,input().split()))
    M = 10**9+7
    l = 1
    for a in A:
        l = lcm(l,a)
    ans = 0
    for a in A:
        ans += l//a
    print(ans%M)
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
As = list(map(int, input().split()))

Bs = []

for i in range(N):
    Bs.append(As[i]-i-1)

Bs.sort()
b = Bs[N//2]

ans = 0

for i in range(N):
    ans += abs(Bs[i]-b)

print(ans)
# Judge status: Accepted
s = input()
k = int(input())

one_counter = 0
for i in range(len(s)):
    if s[i] != "1":
        break
    else:
        one_counter += 1

if s[0] == "1":
    if k <= one_counter:
        res = s[0]
    else:
        res = s[one_counter]
else:
    res = s[0]

print(res)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
ans = 0
maxA = A[0]
for i in range(1,N):
  if A[i] > maxA:
    maxA = A[i]
  else:
    ans = ans + maxA - A[i]
print(ans)
# Judge status: Accepted
X = input()
s_cnt = 0
ans = len(X)
for i in range(len(X)):
    if(X[i] == "S"):
        s_cnt += 1
    else:
        if(s_cnt > 0):
            ans -= 2
            s_cnt -= 1
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

s = S.split("-")

ans = "Yes" if (A == len(s[0]) and B == len(s[1])) else "No"
print(ans)