peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int, input().split()))

#
lim = 10**3 * 2
nums = [0 for _ in range(lim + 1)]
for l in L:
    nums[l] += 1
for i in range(1, lim + 1):
    nums[i] += nums[i-1]

L.sort()

ans = 0
for i in range(N):
    l1 = L[i]
    for j in range(i+1, N):
        l2 = L[j]
        l3_max = (l1 + l2) - 1
        ans += nums[l3_max] - nums[l2]

print(ans)
# Judge status: Wrong Answer
s = input().split()
n = 0
for i in range(len(s) - 1):
  if s[i] != s[i + 1]:
    n += 1
if n >= 1:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
t = list(map(str,input()))
tmpP = 0
cnt = 0

for i in t:
    cnt += 1
    if i == "?":
        if tmpP == 1:
            t[cnt-1] = "D"
            tmpP = 0
        else:
            t[cnt-1] = "P"
            tmpP += 1
    elif i == "P":
        tmpP += 1
    else:
        tmpP = 0

print("".join(t))
# Judge status: Wrong Answer
n,l = map(int,input().split())
n_l = [0]*n
for i in range(n):
    n_l[i] = l + (i+1) - 1
n_l_min = min(n_l)
if n_l_min < 0 :
    print(sum(n_l)-max(n_l))
    exit()
print(sum(n_l)-n_l_min)
#print(n_l)
# Judge status: Accepted
K = int(input())

num = 0
cnt = 0
ans = -1

for i in range(K):
    num = num*10 +7
    cnt += 1
    if num%K != 0:
        num = num%K
    else:
        ans = cnt
        break
    
print(ans)
# Judge status: Accepted
N=input()
ans=0

for i in N:
    ans=ans+int(i)

if ans%9 == 0:
    print("Yes")
    exit()

print("No")
# Judge status: Accepted
a= int(input())
b= int(input())
c= 6
print(c-(a+b))
# Judge status: Accepted
import numpy as np
import itertools
N,M,X=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(N)]
ans=9999999999
 
V=list(itertools.product([0,1], repeat=N))
 
for v in V:
  cost=0
  C=[0]*M
  for n in range(N):
    if v[n]==1:
      cost += arr[n][0]
      for j in range(1,M+1):
        C[j-1] += arr[n][j]
      
  if min(C) >= X:
    ans=min(ans,cost)
    
if  ans ==  9999999999: 
  print(-1)
else:
  print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
r = [a[0]]
for i in range(1, n):
    r.append(r[i - 1] + a[i])
print(min(abs(2 * i - r[-1]) for i in r))
# Judge status: Accepted
dic ={25:"Christmas",24:"Christmas Eve",23:"Christmas Eve Eve",22:"Christmas Eve Eve Eve"}
print(dic[int(input())])
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int, input().split())))[::-1]
print(sum(a for a in A[1:2*n:2]))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
ave = round(sum(A)/N)
all_cost = 0

for a in A:
    cost = (ave - a) ** 2
    all_cost += cost

print(all_cost)
# Judge status: Accepted
W, H, x, y = map(int, input().split())
print(W*H/2, int(x == W/2 and y == H/2))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(b*10+c+a)
# Judge status: Accepted
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in c.items() if m==v])
[print(k) for k in ans]
# Judge status: Accepted
import sys

MOD = 10**9 + 7

N = int(input())
As = list(map(int, input().split()))

sumA = 0
for A in As:
    sumA += A
    sumA %= MOD
#print('# sumA:', sumA, file=sys.stderr)

ans = sumA * sumA % MOD
for A in As:
    ans -= A * A % MOD
    ans %= MOD
#print('# ans:', ans, file=sys.stderr)

inv2 = pow(2, MOD-2, MOD)
ans *= inv2
ans %= MOD

print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
print(max(0, A + B * (N - 1) - (A * (N - 1) + B) + 1))
# Judge status: Accepted
_input = input().split(" ")
for _i in range(5):
  if _input[_i] == "0":
    print(_i + 1)
# Judge status: Accepted
from sys import stdin

n = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()

data = sorted(data, key=int, reverse=True)

alice_total=0
bob_total=0


for i in range(0, n):
    if i % 2 == 0:
        alice_total = alice_total + int(data[i])
    else:
        bob_total = bob_total + int(data[i])

print(alice_total - bob_total)
# Judge status: Accepted
from collections import Counter

n = int(input())
aa = tuple(sorted(map(int, input().split())))
cnt = Counter(aa)
amax = max(aa)
af = [False] * (amax + 1)

ans = 0
for i in range(n):
    x = aa[i]
    if af[x]:
        continue
    while x <= amax:
        af[x] = True
        x += aa[i]
    if cnt[aa[i]] == 1:
        ans += 1

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

b = [0 for i in range(n)]

A = 0

for i in range(n):
  A = A ^ a[i]
  
for i in range(n):
  b[i] = A ^ a[i]

print(b)
# Judge status: Wrong Answer
n,m = map(int,input().split())
A = []
B = []
for i in range(n):
    a_ = input()
    A.append(a_)
for i in range(m):
    b_ = input()
    B.append(b_)

b = 0
for a in A:
    if b == m:
        break
    if "o" in list(a.replace(B[b],"o")):
        b += 1
if b == m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
    print(N*X)
else:
    print(K*X+Y*(N-K))
# Judge status: Accepted
X=int(input())
a=0
if 400<=X<=599:
    a=8
elif 600<=X<=799:
    a=7
elif 800<=X<=999:
    a=6
elif 1000<=X<=1199:
    a=5
elif 1200<=X<=1399:
    a=4
elif 1400<=X<=1599:
    a=3
elif 1600<=X<=1799:
    a=2
elif 1800<=X<=1999:
    a=1

print(a)
# Judge status: Accepted
N,T=map(int,input().split())
cost=10001
ans=-1
for i in range(N):
    c,t=map(int,input().split())
    if t<=T and c<cost:
        cost=c
        ans=cost
if ans==-1:
    print('TLE')
else:
    print(ans)
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    arr = A[0]
    ans = 0
    for i in A:
        ans += abs(arr - i) if i <= arr else 0
        arr = max(arr, i)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
X = input()
X = int(X)

if X >= 30:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a = input().split()
a=[int(i) for i in a]
n,k=a[0],a[1]
r=0
b=1
while r<1:
    if n>=k**b:
        b=b+1
    else:
        r=1
print(b)
# Judge status: Accepted
S = input()
S = sorted(S)

if S ==  list("abc"):
    print("Yes")
else:print("No")
# Judge status: Wrong Answer
a, b, n = map(int, input().split())
print(int(a*n/b) - a*int(n/b))
# Judge status: Wrong Answer
#!/usr/bin/env python3

n, a, b, c, d, e = [int(input()) for _ in range(6)]

ans = (n-1)//min(a, b, c, d)+1 + 4
print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
x = list(map(int, input().split()))
num = math.ceil(sum(x)/n)

cost=0
for i in range(n):
    cost += (x[i]-num)*(x[i]-num)
print(cost)
# Judge status: Wrong Answer
x,k,d=map(int,input().split())

num_moved = x // d
num_remained = k - num_moved
if num_remained >= 0:
  now = x % d
else:
  now = x - d*k

#now = x % d
if num_remained % 2 == 0:
  result = abs(now)
else:
  tmpa = now + d
  tmpb = now - d
  if abs(tmpa) > abs(tmpb):
    result = abs(tmpb)
  else:
    result = abs(tmpa)
print(result)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

ans = a[0]
for i in range(2,n):
    ans += a[i//2]

print(ans)
# Judge status: Accepted
n=input()
l=sorted(map(int,input().split()))
n=len(l)
if n<3:
  print(0)
  exit()
c=0
for i in range(n-2):
  for j in range(i,n-1):
    for k in range(j,n):
      if l[i]==l[j]:
        continue
      if l[j]==l[k]:
        continue
      if l[i]+l[j]>l[k]:
        c+=1
print(c)
# Judge status: Accepted
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def divnum(n):
    res=0
    for i in range(1,n+1):
        if n%i==0:
            res+=1
    if res==8:
        return True
    else:
        return False
count=0
for i in range(1,n+1):
    if i%2!=0 and divnum(i):
        count+=1
print(count)
# Judge status: Accepted
N = int(input())
A = sorted(map(int, input().split()))

colors = [0] * 9
for a in A:
    idx = a // 400
    if idx >= 8:
        idx = 8
    colors[idx] += 1
ans = 0
for i in range(8):
    if colors[i] > 0:
        ans += 1
max_ans = ans
if colors[8] > 0:
    max_ans += colors[8]

if ans == 0 and max_ans > 0:
    ans += 1
print(ans, max_ans)
# Judge status: Accepted
a, b, c ,k = map(int, input().split())

ak = min(a, k)
k -= ak
if k == 0:
    ans = ak
    print (ans)
else:
    bk = min(b, k)
    k -= bk
    if k == 0:
        ans = ak
        print (ans)
    else:
        ck = k
        ans = ak- ck
        print (ans)
# Judge status: Wrong Answer
from math import sqrt

ans = 0
n,d = map(int,input().split())
for i in range(n):
    x,y = map(int,input().split())
    ans += 1 if sqrt((x**2)+(y**2)) >= d else 0
print(ans)
# Judge status: Accepted
n = int(input())
l = []
for i in range(1,n+1):
    s,p = input().split()
    l.append((s,100-int(p),i))

l.sort()
for item in l:
    print(item[2])
# Judge status: Wrong Answer
a,b,k=map(int, input().split())
print( max(0,a-k), min([0,b,a+b-k]) )
# Judge status: Accepted
X, Y = map(int, input().split())

ans = 0
while X <= Y:
    X *= 2
    ans += 1
print(ans)
# Judge status: Wrong Answer
import numpy as np   
n,m = [int(i)for i in input().split()]

l = [[int(i)-1 for i in input().split()] for _ in range(m)]

line = np.array([1 for _ in range(n)])
is_red = np.zeros(n,dtype = np.int32)
is_red[0] = 1

for x,y in l:
    line[x] -= 1 if line[x] > 0 else 0
    line[y] += 1
    is_red[y] = 1 if is_red[x] == 1 else 0
    

ans = np.count_nonzero(is_red[line > 0])

print(ans)
# Judge status: Wrong Answer
n=int(input())
print((22/7)*n*n)
# Judge status: Accepted
n, m = map(int, input().split())

s = input()

d = [0] * n
cnt = 0
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
       cnt += 1
    d[i+1] = cnt

for _ in range(m):
    a, b = map(int, input().split())
    print(d[b-1] - d[a-1])
# Judge status: Accepted
N,A,B = map(int, input().split())

#print(N,A,B)
if A>B:
  print(0)
elif (N==1 and A!=B):
  print(0)
elif (N==1 and A==B):
    print(1)
else:
  print((B-A)*(N-2)+1)
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if A[i] >= A[i+1]:
        ans += A[i]-A[i+1]
        A[i+1] = A[i]
print(ans)
# Judge status: Wrong Answer
def abc174_e():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    if k == 0: return max(A)

    lower, upper = 0, 10**9
    while upper - lower > 1:
        x = (upper + lower) // 2
        cnt = 0
        for a in A:
            cnt += a // x
            if cnt > k: break
        if cnt > k: lower = x
        else: upper = x
    return upper

if __name__ == '__main__':
    print(abc174_e())
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(1,n+1):
    ans += a[-2*i]

print(ans)
# Judge status: Accepted
N = int(input())
D = [input().split() for l in range(N)]

zoro = []
for i in range(N):
  if D[i][0] == D[i][1]:
    zoro.append(1)
  else:
    zoro.append(0)

cnt = []
for i in range(N-2):
  cnt.append(zoro[i]+zoro[i+1]+zoro[i+2])
  

zoro_cnt = 0
for i in range(N-2):
  if cnt[i] == 3:
    zoro_cnt += 1


if zoro_cnt >= 1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import numpy as np
import sys

input = sys.stdin.readline

alp = "abcdefghijklmnopqrstuvwxyz"
alp = list(alp)

w = sorted(input())
w = w[1:]

#print(w)
cnt = 1
for i in range(1,len(w)):
#    print( w[i],cnt)
    if w[i] ==w[i-1] :
        cnt +=1
    else:
        if cnt%2 == 1:
            print("No")
            exit()
        else:
            cnt = 1

if len(w) == 1:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(m):
        print(i + 1, n - i)
else:
    for i in range(m):
        if 2 * (i + 1) <= m + 1:
            print(i + 1, n - i)
        else:
            print(i + 1, n - i - 1)
# Judge status: Accepted
X = int(input())

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)
# Judge status: Wrong Answer
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
elif m==1:
    if k==0: print(0,0,1,1)
    else: print(-1)
else:
    tmp=k
    for i in range(1,2**m):
        tmp^=i
    ans=[i for i in range(2**m) if i!=k]+[k]+[i for i in range(2**m-1,-1,-1) if i!=k]+[k]
    print(*ans)
# Judge status: Wrong Answer
N,Y = map(int,input().split())
for x in range(N):
    for y in range(N):
        if Y == 10000*x+5000*y+1000*(N-x-y):
            print(x,y,N-x-y)
            exit()
print('-1','-1','-1')
# Judge status: Accepted
a=int(input())
b=int(input())
h=int(input())

print((a+b)*h//2)
# Judge status: Accepted
n = int(input())
n1 = n//100
n2 = n%100
if 0<n1<13 and 0<n2<13: print("AMBIGUOUS")
elif 0<n1<13: print("MMYY")
elif 0<n2<13: print("YYMM")
else: print("NA")
# Judge status: Accepted
import sys
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
if N >= M:
    print(0)
    sys.exit()
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))
# Judge status: Accepted
l = list(map(int, input().split()))
print('bust' if sum(l) >= 22 else 'win')
# Judge status: Accepted
x=int(input())
ans,i=0,0
while i < x:
    i+=ans
    ans+=1
print(ans-1)
# Judge status: Wrong Answer
import math
s,l,h,m=map(int,input().split())
#JIKOKU
t=60*h+m
#TANSHIN KAKUDO
sd=(0.5*t)%360
ld=(6*t)%360
x=abs(sd-ld)

if x==180:
    print(s+l)
    exit()
elif x==0:
    print(l-s)
elif x>180:
    x=x-180

radx=math.radians(x)
cosx=math.cos(radx)

print((s**2+l**2-2*l*s*cosx)**0.5)
# Judge status: Wrong Answer
import math
import itertools

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

xn = []
for i in range(n):
  x = [int(num) for num in input().split()]
  xn.append(x)

c_list = list(itertools.combinations([int(num) for num in range(n)], 2))  
  
answers = []
for c in c_list:
  sum = 0
  for j in range(d):
    sum += (xn[c[0]][j]-xn[c[1]][j])**2 
  
  answers.append(int(math.sqrt(sum)*10))  

count = 0
for a in answers:  
  if a%10 == 0:
    count += 1
 
print(count)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
pre=sum(A)

for i in range(N):
  if B[i]<=A[i]:
    A[i]-=B[i]
  else:
    A[i+1]=max(0, B[i]-A[i])
    A[i]=0
print(sum(A)-pre)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
count = [0]*10**5
for i in a:
    count[i] += 1
ans = []
for i in range(len(count)-2):
    ans.append(sum(count[i:i+3]))
print(max(ans))
# Judge status: Accepted
n,p = map(int,input().split())
a = list(map(int,input().split()))
ans = o = e = 0
for i in a:
    if i%2==0:e+=1
    else:o+=1

from math import factorial
ec = 0
for i in range(e+1):
    ec += factorial(e)//(factorial(e-i)*factorial(i))
oc = 0
if p==0:
    for i in range(o+1):
        if i%2==0:
            oc += factorial(o)//(factorial(o-i)*factorial(i))
else:
    for i in range(o+1):
        if i%2==1:
            oc += factorial(o)//(factorial(o-i)*factorial(i))
print(oc*ec)
# Judge status: Accepted
n,t = map(int, input().split())

res = 10000

for i in range(n):
    a,b = map(int, input().split())
    if b <= t:
        res = min(res,a)

if res ==10000:
    print("TLE")
else:
    print(res)
# Judge status: Wrong Answer
import fractions

a,b,c,d=map(int,input().split())
C=int(b//c)-int((a-1)//c)
D=int(b//d)-int((a-1)//d)
g=fractions.gcd(c,d)
l=(c*d)/g
E=int(b//l)-int((a-1)//l)
print(int(b)-int(a)+1-int(D)-int(C)+int(E))
# Judge status: Accepted
A, B, C = map(int, input().split())
sum = 0
before = set()
while True:
    if str(A)+' '+str(B)+' '+str(C) in before:
        print(-1)
        exit()
    else:
        before.add(str(A)+' '+str(B)+' '+str(C))
    if A%2==1 or B%2==1 or C%2==1:
        print(sum)
        exit()
    temp1 = int(B/2)+int(C/2)
    temp2 = int(A/2)+int(C/2)
    temp3 = int(A/2)+int(B/2)
    A, B, C = temp1, temp2, temp3
    sum += 1
# Judge status: Accepted
mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1
x=1
p=1
for i in range(a):
    p=p*(n-i)
    p%=mod
    x=x*(i+1)
    x%=mod
tmp1=(p*pow(x,mod-2,mod))%mod
y=1
q=1
for j in range(b):
    q=q*(n-j)
    q%=mod
    y=y*(j+1)
    y%=mod
tmp2=(q*pow(y,mod-2,mod))%mod
print((ans-tmp1-tmp2)%mod)
# Judge status: Wrong Answer
a,b,c=[int(i) for i in input().split()]
if a>=b:
  if a>=c and c>=b:
    print('Yes')
  else:
    print('No')
else:
  if b>=c and c>=a:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
import sys
r = int(input())
S = r*r
print(S)
# Judge status: Accepted
S =int(input())
joy_500 = (S // 500) * 1000
joy_5 = ((S-(joy_500 // 2)) // 5) * 5
print(joy_500+joy_5)
# Judge status: Accepted
A,B=map(int,input().split())
C=max(A,B)
if C==A:
  D=max(A-1,B)
else:
  D=max(A,B-1)
print(C+D)
# Judge status: Wrong Answer
hi = "hi"
S = input()

if hi in S:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
def main():
  N, M= map(int, input().split())
  a =[str(input()) for _ in range(M)]
  DP = [0]*(N+1)
  num = 1000000007
  DP[0] = 1
  for i in range(N):
    if str(i) in a:
      DP[i] = (DP[i-1] + DP[i-2]) % num
  print(DP[-2]%num)
if __name__ == "__main__":
    main()
# Judge status: Accepted
s = input()
L = ""
for i in s:
  if i == "B":
    if L:
      L = L[:-1]
  else:
    L += i
print(L)
# Judge status: Wrong Answer
S = input()[0:3]
res = 0
if S == 'RRS' or S == 'rrs':
    res = 2
elif S=='RRR' or S == 'rrr':
    res = 3
elif S=='RSR' or S == 'rsr':
    res =1
elif S=='RSS' or S=='rss':
    res = 1
else:
    res = 0
print(res)
# Judge status: Wrong Answer
# 標準出力を取得（strデータ）
A, B = input().split()

# A, B を integerに変換
A = int(A)
B = int(B)

# OAタップの数を表す変数の初期値を 1 とする
num = 1


if A == 1 & B == 1:
    num = 0
else:
    while (A - 1) * (num - 1) + A < B:
        num = num + 1

# 結果を出力
print(num)
# Judge status: Accepted
N = int(input())
A = [[0,0,0]]
for i in range(N):
  A.append(list(map(int, input().split())))

flag = True
for i in range(N):
  if not flag:
    break
  time = int(A[i+1][0]) - int(A[i][0])
  dist = abs(A[i+1][1] - A[i][1]) + abs(A[i+1][2] - A[i][2]) # x2-x1 + y2-y1
  if time < dist:
    flag = False
  elif time % 2 != dist % 2:
    flag = False

if flag:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
x, a, b = map(int,input().split())
 
if 0 >= (b - a):
  print("delicious")
elif x <= (b - a):
  print("dangerous")
else:
  print("safe")
# Judge status: Accepted
n = int(input())
f = 1
m = 10**9+7
for i in range(1,n+1):
  f = f%m * i
print(f%m)
# Judge status: Wrong Answer

ABC = set(input())

print("Yes"if len(ABC)==2 else "No")
# Judge status: Accepted
N, M = map(int, input().split())
road = [list(map(int, input().split())) for _ in range(M)]
city = [0]*N
for r in road:
    city[r[0] - 1] += 1
    city[r[1] - 1] += 1
print(*city,sep="\n")
# Judge status: Wrong Answer
N=int(input())
j=0
for i in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    j+=1
  else:
    j=0
if j>=3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)
# Judge status: Accepted
N=int(input())
C=[0]*(N-1)
S=[0]*(N-1)
F=[0]*(N-1)
for i in range(N-1):
  C[i],S[i],F[i]=map(int,input().split())
  
for i in range(N):
  j=i
  t=0
  while j<N-1:
    if t<=S[j]:
      t=S[j]
    else:
      tmp= t-S[j]
      s=tmp%F[j]
      if s!=0:
        t += F[j]-s
    #print(i,j,t)
    t += C[j]
    j +=1
  print(t)
# Judge status: Wrong Answer
N,M=map(int,input().split())
if 2*N>=M:
    print(N)
if 2*N<M:
    L=M-2*N
    print(N+L//4)
# Judge status: Wrong Answer
n,m = map(int,input().split())
pn = [0] * n
aw = [0] * n

for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == "WA":
        if aw[p] == 0:
            pn[p] += 1
    else:
        aw[p] = 1

print ("%d %d" % (sum(aw),sum(pn)))
# Judge status: Accepted
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
# n, k = 5, 3
# nums = [-30, -10, 10, 20, 50]

m = 10 ** 10
# 左から
for i in range(n-k+1):
    m = min(m, abs(nums[i]) + nums[i+k-1] - nums[i])

# 逆で考えるのindex的に大変なので-1をかけて反転する
nums = nums[::-1]
nums = [num * -1 for num in nums]

# 本当は関数化すべき
for i in range(n-k+1):
    m = min(m, abs(nums[i]) + nums[i+k-1] - nums[i])
print(m)
# Judge status: Wrong Answer
N = int(input())
S=[]
for _ in range(N):
    S.append(input())

C = [0,0,0,0]
judge = ['AC','WA','TLE','RE']

for i in range(N):
    for j in range(4):
        if judge[j]==S[i]:
            C[j]=C[j]+1

for k in range(4):
    print(f'{judge[k]} ×　{C[k]}')
# Judge status: Wrong Answer
ae = [int(input()) for i in range(5)]

mm = ae[0]%10
for i in range(5):
    mm = min(mm, ae[i]%10)
    ae[i] = ((ae[i]//10)+1)*10

print(sum(ae)-(10-mm))
# Judge status: Accepted
a,b = map(int,input(). split ())
print(a*b)
# Judge status: Accepted
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]
n,m=map(int, input().split())
ans=0
for i in make_divisors(m):
  if m//i>=n:
    ans=i
print(ans)
# Judge status: Accepted
N = input()
A = sorted([int(x) for x in input().split()])
import bisect as bs
ans = 0
f = lambda X, x: bs.bisect_right(X,x) - bs.bisect_left(X,x)
for a in set(A):
    cnt = f(A,a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt-a
print(ans)
# Judge status: Accepted
n = int(input())
l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in l:
    if i >= n:
        print(i)
        break
# Judge status: Accepted
import math
a, b = map(int, input().split())

def solve(x):
    return math.floor(x * 0.08) == a and math.floor(x * 0.1) == b

for i in range(1, 10**5):
    if solve(i):
        print(i)
        exit()

print(-1)
# Judge status: Wrong Answer
import sys


def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


def input():
    return sys.stdin.readline().rstrip()


#############
# Main Code #
#############
a = getN()
b = getN()
h = getN()
print((a + b) / 2 * h)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
dst = p[:]
asc = list(range(1, n+1))
can = (dst == asc)
for i in range(n-1):
    if can:
        break
    for j in range(i+1, n):
        dst[i], dst[j] = dst[j], dst[i]
        can = (dst == asc)
        dst = p[:]
print("YES" if can else "NO")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

x = int(input())

cnt = -(-x//11)
if cnt*11-x>=5:
    print(cnt*2-1)
else:
    print(cnt*2)
# Judge status: Wrong Answer
N, M, Q = map(int, input().split())
reqs = [list(map(int, input().split())) for _ in range(Q)]
 
As = []
 
def make(A):
  global As, N, M
  if len(A) == N+1:
    As.append(A)
  else:
    for i in range(A[len(A)-1], M+1):
      A.append(i)
 
make([1])
 
max = 0
for A in As:
  score = 0
  for req in reqs:
    if A[req[1]] - A[req[0]] == req[2]:
      score += req[3]
  max = max(score, max)
 
print(max)
# Judge status: Wrong Answer
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N = int(input())
    AN = list(map(int, input().split()))

    AN_lcm = lcm_list(AN) % 10**9 + 7

    ans = 0
    for A in AN:
        ans += AN_lcm // A
        ans %= 10**9 + 7

    print(ans)


main()