peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

n = ni()
a = na()

c = collections.Counter(a)

k = 0
for i,j in sorted(c.items())[::-1]:
    if j < 2:
        continue
    if k > 0:
        print(k*i)
        exit()
    elif j >= 4:
        print(i*i)
        exit()
    else:
        k = i

print(0)
# Judge status: Wrong Answer
N = int(input())
W = [list(input().split()) for _ in range(N)]
S = sorted(W)
for i in range(N):
  for j in range(i+1, N):
    if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]):
      a = S[i]
      S[i] = S[j]
      S[j] = a
    else:
      break
for k in range(N):
  print(W.index(S[k])+1)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
k,a,b=map(int,input().split())
if b/a<=2 or k-1<a:
    print(1+k)
else:
    print((k-a+1)//2*(b-a)+(k-a+1)%2+a)
# Judge status: Accepted
S=input()
L=["SUN","MON","TUE","WED","THU","FRI","SAT" ]
for i in range(len(L)):
    if S==L[i]:
        print(len(L)-i)
        exit(0)
# Judge status: Accepted
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
#print(aji)
total = sum(aji)
#print(total)

eat = 1000
j=0
for i in range(N):
  if eat > abs(aji[i]):
    eat = abs(aji[i])
    # eat  は正の値

if min(aji) >0:
  print(total-eat)
else:
  print(total+eat)
# Judge status: Accepted
# C - Christmas Eve

N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()
diffs = []
for i in range(K-1, N):
    diffs.append(h[i] - h[i-(K-1)])

print(min(diffs))
# Judge status: Wrong Answer
print(exec(input().replace(" ","+")+"//2"))
# Judge status: Accepted
n = int(input())
flag = 0

for i in range(14):
  for j in range(25):
    if 7*i + 4*j == n:
      flag = 1
      break

if flag:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    str = S[:K]+'...'
    print(str)
# Judge status: Accepted
A,B,C=map(int,input().split())
print(min(C,B//A))
# Judge status: Wrong Answer
import collections
import copy

def f(l):
    return l*(l-1)


n=int(input())
a=list(map(int,input().split()))
b=collections.Counter(a)
print(b)

for x in a:
    c=copy.deepcopy(b)
    c[x]-=1
    d=c.values()
    e=0
    for y in d:
        e+=f(y)
    print(e//2)
# Judge status: Accepted
n, k = map(int,input().split())
x = list(map(int, input().split()))

lis = [0]
for i in range(1,n):
    lis.append(lis[i-1] + abs(x[i]-x[i-1]))
#print(lis)
#print(x)
ans = int(1e10)
for i in range(n-k+1):
    val = min(abs(x[i]),abs(x[i+k-1])) + (lis[i+k-1]-lis[i])
    #print(val,ans)
    #print(ans)
    if val < ans:
        ans = val

print(ans)
# Judge status: Accepted
from collections import defaultdict

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

hasOne = defaultdict(bool)
E = []

for a in A:
  if not hasOne[a]:
    hasOne[a] = True
  else:
    E.append(a)
    hasOne[a] = False

E.sort(reverse=True)

if len(E) < 2:
  print(0)
else:
  print(E[0] * E[1])
# Judge status: Accepted
l,r,d = map(int, input().split())
ans=0

for i in range(l,r+1):
    if (i%d == 0): ans += 1

print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = [int(x) for x in input().rstrip()][::-1] + [0]
L = len(N)

dp = [[10 ** 18, 10 ** 18] for _ in range(L)]
dp[0] = [N[0], 10 - N[0]]

for i in range(1, L):
    n = N[i]
    dp[i][0] = min(dp[i - 1][0] + n, dp[i - 1][1] + (n + 1))
    dp[i][1] = min(dp[i - 1][0] + (10 - n), dp[i - 1][1] + (10 - (n + 1)))

print(dp[-1][0])
# Judge status: Accepted
from collections import Counter

S=input()

rlist=[0]
for i in range(len(S)):
  rlist.append((rlist[-1]+int(S[-i-1])*pow(10,i,2019))%2019)
  
c = Counter(rlist)
c[0] -= 1

def nC2(n):
  return n*(n-1)//2
  
ans = c[0]
for k in c.keys():
  if c[k] >= 2:
    ans += nC2(c[k])
    
print(ans)
# Judge status: Wrong Answer
K, N = map(int, input().split())
an = list(map(int, input().split()))


dis =[]

dis.append(an[0] + K - an[len(an)-1])

for i in range(N-1):
    dis.append(an[i+1]-an[i])

work = sorted(dis)
print(work[0]+ work[1])
# Judge status: Accepted
s = input()

max = 0
count = 0

for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
    count += 1
    if max < count:
      max = count
  else:
    count = 0

print(max)
# Judge status: Accepted
S=input()
now=""
ans=0
flag=0
for s in S:
    if flag==1: #2文字目に突入したとき
        now=""
        ans+=1
        flag=0
    else:
        if now==s:
            flag=1
        else:
            now=s
            ans+=1
print(ans)
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
no1 = ''
for i in range(ty-sy):
    no1 += 'U'
for i in range(tx-sx):
    no1 += 'R'
no2 = ''
for i in range(ty-sy):
    no2 += 'D'
for i in range(tx-sx):
    no2 += 'L'
print(no1+no2+'LU'+no1+'RD'+'RD'+no2+'LU')
# Judge status: Accepted
import sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    b = sum(map(lambda x: (x >> i)&1, a))
    c = n - b
    ans += b * c * i % mod
print(ans%mod)
# Judge status: Accepted
n= int(input())
a = list(map(int,input().split()))
allsum= sum(a)
ans = 0
for i in range(n):
    allsum = allsum -a[i]
    ans += a[i]*allsum
o = ans % (10**9+7)
print(o)
# Judge status: Accepted
def main():
    a, b = map(int, input().split())
    if a >= 13:
        ans = b
    elif a >= 6:
        ans = int(b / 2)
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import functools
import operator

n = functools.partial(functools.reduce, operator.mul)
N,K = map(int,input().split())
A = list(map(int,input().split()))
# print(n(A))
for i in range(K,N):
    if A[i-K] < A[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            print("DENIED")
            break
else:
    print("APPROVED")
# Judge status: Wrong Answer
a, b, n = map(int, input().split())
print((b-a+1)//n)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

num_buf = [0] * n

for i in range(n - 1):
    num_buf[a[i] - 1] += 1

for i in range(len(num_buf)):
    print(num_buf[i])
# Judge status: Accepted
n = int(input())

p = list(map(int,input().split()))

ans = 0
for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1] :
        ans += 1
    elif p[i+1] < p[i] and p[i] < p[i-1] :
        ans += 1
print(ans)
# Judge status: Accepted
l=list(map(int,input().split()))
l.sort(key=int)
print(int(str(l[-1])+str(l[-2]))+l[0])
# Judge status: Accepted
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y == 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)
# Judge status: Accepted
n = int(input())
a = 0
for i in range(1,n+1):
    if not ((i%3 == 0)or (i%5 == 0)):
        a += i
print(a)
# Judge status: Wrong Answer
n=int(input())
length = len(str(n))
ans = 0
if(length%2==1):
    ans += n%(10**(length-1))
for i in range(0,length-1):
    if(i%2==1):
        ans +=10**i
print(ans)
# Judge status: Wrong Answer
d,n = map(int,input().split())

if d == 0:
  num = 1 * n
  print(num)
if d == 1:
  num = 100 * n
  print(num)
if d == 2:
  num = 10000 * n
  print(num)
# Judge status: Accepted
N, A, B = map(int, input().split())
if A>B:
    print(0)
    exit()
ans = (B*(N-1)+A) - (A*(N-1)+B) + 1
print(max(ans,0))
# Judge status: Wrong Answer
def main():
    N, M = map(int, input().split())
    A = set()
    for _ in range(M):
        a = int(input())
        A.add(a)
    mod = 10**9 + 7
    dp = [0] * (N+1)
    dp[0] = 1
    if 1 not in A:
        dp[1] = 1
    for i in range(1, N+1):
        if i not in A:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= mod
    return dp[-1]
print(main())
# Judge status: Accepted
s = input()
n = len(s)
ans = 1
l = ''
k = s[0]
for i in range(1,n):
    
    
    if l + s[i] != k :
        k =  l + s[i] 
        l =''
        ans += 1
    else:
        l += s[i]
print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]
    ans = list()
    for i in range(N):
        ans.append(sum(A[0][0:i+1]) + sum(A[1][i:]))
    print(max(ans))


if __name__ == "__main__":
    main()
# Judge status: Accepted
x=int(input())
if x==2:
    print(2)
else:
    while True:
        cnt=0
        if x%2==0:
            x+=1
            continue
        for i in range(2,x):
            if x%i==0:
                cnt=1
                continue
        if cnt==1:
            x+=1
        else:
            print(x)
            break
# Judge status: Accepted
import math
X= int(input())
ans = 0
get = 100.0
while  X > get:
    ans += 1
    get += math.floor(get*0.01)

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Accepted
n = int(input())
a = int(input())

if n % 500:
  if (n % 500) <= a:
    print("Yes")
  else:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
A=input()
B=int(9)
i,j=divmod(int(A),int(B))
if j == 0:
  j="Yes"
else:
  j="No"
print(j)
# Judge status: Accepted
N,M = map(int,input().split())
if M//N < 2:
    print(M//2)
else:
    # 交換できる回数の最大値は M - 2x = 2*(N + x) より求めた
    x = (M-2*N)//4
    print(N+x)
# Judge status: Accepted
x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0:
        print(i+1)
        break
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if A >= K:
    nmax = K
elif B >= K-A:
    nmax = A
else:
    nmax = A-(K-A-B)
            
print(nmax)
# Judge status: Wrong Answer
n,m = map(int,input().split())
x = []
y = []
for _ in range(n):
    a,b = map(int,input().split())
    x.append([a,b])
for _ in range(m):
    c,d = map(int,input().split())
    y.append([c,d])
for i in range(n):
    t = 10**8*2
    ans = 0
    for j in range(m):
        if t > abs(y[j][0]-x[i][0])+abs(y[j][1]-x[i][1]):
            ans = j+1
            t = abs(y[j][0]-x[i][0])+abs(y[j][1]-x[i][1])
    print(ans)
# Judge status: Accepted
import sys
K=int(input())

if K%2==0 or K%5==0:
  print(-1)
  sys.exit(0)

k_mod=0
seven_k=0
for i in range(1,K+1):
  k_mod=10*k_mod+7
  k_mod%=K
  if k_mod==0:
    print(i)
    break
else:
  print(-1)
# Judge status: Accepted
import sys
import numpy as np

h, n = map(int, input().split())
ab = np.array(sys.stdin.read().split(), dtype=np.int64)
aaa = ab[0::2]
bbb = ab[1::2]

dp = np.zeros(10001, dtype=np.int64)
for i in range(1, h + 1):
    dp[i] = (dp[i - aaa] + bbb).min()
print(dp[h])
# Judge status: Accepted
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
# Judge status: Accepted
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
a,b,c,d,k=map(int,input().split())
strt=a*60+b
end=c*60+d
print(end-k-strt)
# Judge status: Wrong Answer
s, t = input().split()
a, b = map(int, input().split())
u=input()

if(u==s):
  print(a-1)
else:
 print(b-1)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print("No" if (a<b and b<c) or (c<b and b<a) else "Yes")
# Judge status: Accepted
def main():
    n = int(input())

    for i in reversed(range(1,n+1)):
        if (i ** 0.5).is_integer():
            print(i)
            exit()

if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if A <= K:
    ans = 1 * A
    K = K - A
else:
    ans = K
    print(ans)
    exit(0)

if 0 < K:
    ans = ans + 0 * B
    K = K - B

if 0 < K:
    ans = ans + (-1) * K

print(ans)
# Judge status: Accepted
n, m, x = map(int, input().split())
sup = [0]*n 
cost = [0]*n

for i in range(n):
  CA = list(map(int, input().split()))
  cost[i] = CA[0]
  sup[i] = CA[1:]
  
ans = -1

for i in range(2**n):
  skills = [0]*m
  c = 0
  for j in range(n):
    if i>>j&1:
      c += cost[j]
      for k in range(m):
        skills[k] += sup[j][k]
  if min(skills)>=x:
    if ans < 0:
      ans = c
    elif c<ans:
      ans = c
    
print(ans)
# Judge status: Accepted
n,r = map(int,input().split())

if n>10 :
    ans = r
else:
    ans = r+(100*(10-n))
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [tuple(map(int, input().split())) for _ in range(M)]
for x in range(10 ** N):
  f = 1
  for i in range(M):
    s = str(x)
    y, c = t[i]
    if len(s) < y or (len(s) < N):
      f = 0
      break
    if int(s[y - 1]) != c:
      f = 0
      break
  if f:
    print(x)
    exit(0)
print(-1)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=[]
    n=int(input())
    for i in range(n):
        s,p=input().split()
        ll=[s,int(p),i+1]
        l.append(ll)
    lll = sorted(l, key=lambda x:x[1], reverse=True)
    llll=sorted(lll,key=lambda x:x[0])
    for s,p,i in llll:
        print(i)
resolve()
# Judge status: Accepted
import math
x = int(input())
for i in range(x, x * 2):
    flag = True
    for j in range(2, math.floor(math.sqrt(x))+1):
        if i % j == 0:
            flag = False
            break
    if flag:
        print(i)
        exit(0)
# Judge status: Accepted
s = input().strip()

counts = {
    'N': 0, 'W': 0, 'S': 0, 'E': 0
}

for c in s:
    counts[c] += 1


def judge():
    if counts['N'] > 0 or counts['S'] > 0:
        if counts['N'] * counts['S'] == 0:
            return False

    if counts['W'] > 0 or counts['E'] > 0:
        if counts['W'] * counts['E'] == 0:
            return False

    return True


if judge():
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())

n = str(N)

le = len(n)

M = []

for i in range(le):
    nn = int(n[i])
    M.append(nn)

if sum(M) % 9 == 0:
    print("Yes")
else:
    print("No")

print(M)
# Judge status: Accepted
N,K=map(int,input().split())
A=[int(a)-1 for a in input().split()]

if K<=N:
  p=0
  for i in range(K):
    p=A[p]
  print(p+1)
  exit()
p=0
t=[-1]*N
t[0]=0
for i in range(1,N):
  p=A[p]
  if t[p] !=-1:
    break
  t[p]=i

d=i-t[p]
K-=i
K%=d
for i in range(K):
  p=A[p]
print(p+1)
# Judge status: Accepted
A, B = map(str.strip, input().split())

print(sorted([A*int(B), B*int(A)])[0])
# Judge status: Wrong Answer
n=list(map(int, input().split()))
 
for i in range(len(n)):
  if n[i]==n[i-1]:
    print('Bad')
    break
else:
  print('Good')
# Judge status: Accepted
N = int(input())
S = input()
T = input()

if S == T:
    print(N)
else:
    ans = 2 * N
    for i in range(N):
        if S[i:] == T[:N - i]:
            ans -= len(S[i:])
            break
    print(ans)
# Judge status: Wrong Answer
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff - 1) / 2 + 1

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(round(ans))
# Judge status: Accepted
a=int(input())
n=list(map(int,input().split()))
m=list(map(int,input().split()))
o=list(map(int,input().split()))
result1=0

for i in range(0,a-1):
    if n[i]+1==n[i+1]:
        result1+=o[n[i]-1]

for i in range(a):
    result1+=m[n[i]-1]
print(result1)
# Judge status: Accepted
from heapq import *
n,m=map(int,input().split())
ab=[]
ans=[[] for i in range(m)]
aa=0
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b*=-1
    ab.append((a,b))
ab.sort()
t=[]
heapify(t)
for a,b in ab:
    if a<m:
        ans[a].append(b)
for i in range(m):
    for j in ans[i]:
        heappush(t,j)
    if len(t)>0:
        tt=heappop(t)*(-1)
        aa+=tt
print(aa)
# Judge status: Wrong Answer
N = int(input())
a = [int(i) for i in input().split()]
ans = []
for x in a:
    s = '1'*(len(str(x)))
    ans.append(x^int(s))
print(*ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

print(abs(a-b))
if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    N = int(input())
    permutation = list(map(int, input().split()))
    answer = 0
    for i in range(N):
        if permutation[i] == i + 1:
            if permutation[i] == N:
                permutation[i], permutation[i - 1] = permutation[i - 1], permutation[i]
            else:
                permutation[i], permutation[i + 1] = permutation[i + 1], permutation[i]
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())

res = 1
while (res << 1) < N:
    res = res << 1
print(res)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

score = - a[0]
for i in range(n):
    score += a[i // 2]
print(score)
# Judge status: Accepted
import math
import itertools
#n = int(input())
#n, d = list(input().split())
A, B, X= list(map(int, input().split()))

if A == X or (A < X and A+B > X) :
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import math

N, K = map(int, input().split())
K = min(41, K)
A = list(map(int, input().split()))
A.insert(0, 0)

def operation():
  global A, N
  B = [0] * (N+1)
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    if right+1 <= N:
      B[right+1] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]
  return B


operation()

#print(A)
#print(B)

for _ in range(K):
  A = operation()

print(*A[1:])
# Judge status: Accepted
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
  a = list(map(int,input().split()))
  for j in range(3):
    d[a[j]] = 3*i+j+1
f = [False for _ in range(10)]

N = int(input())
for _ in range(N):
  b = int(input())
  f[d[b]] = True
  
ans = False

for i in range(3):
  ans = ans or (f[3*i+1] and f[3*i+2] and f[3*i+3])
  ans = ans or (f[i+1] and f[i+4] and f[i+7])
  
ans = ans or (f[1] and f[5] and f[9])
ans = ans or (f[3] and f[5] and f[7])

if ans:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

i = 1

for j in range(N):
  if i == a[j]:
    i += 1

if i == 1:
  print(-1)
else:
  print(N+1-i)
# Judge status: Accepted
X,Y,Z=map(int,input().split());print(Z,X,Y)
# Judge status: Accepted
n,x,y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * (n-1)

for j in range(n):
  for i in range(j):
    ans[min(j-i, abs(x-i)+1+abs(j-y)) - 1] += 1

print("\n".join([str(d) for d in ans]))
# Judge status: Accepted
n = int(input())
A=[int(i) for i in input().split()]

t = 1
ans=0
for i in A:
    if i==t:
        t+=1
    else:
        ans+=1
print(ans if t!=1 else -1)
# Judge status: Accepted
N=int(input())
n=0
S=1
while S<N:
    n+=1
    S=n*(n+1)//2

if N==1:
    print(1)

for i in range(1,n+1):
    if i!=S-N:
        print(i)
# Judge status: Wrong Answer
#ABC056-C
import bisect
x = int(input())
a = [int(0.5*(i+i**2)) for i in range(10**3)]

if x in set(a):
    print(a.index(x))
else:
    print(bisect.bisect_left(a,x))
# Judge status: Accepted
S = input()
North = S.count("N")
South = S.count("S")
East = S.count("E")
West = S.count("W")
if ((North > 0 and South > 0) or (North == 0 and South == 0)) and ((East > 0 and West > 0) or (East == 0 and West == 0)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
 
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

mod = 10**9 + 7

l = A[0]
for i in range(1,N):
    l = (A[i]//gcd(A[i],l))*l


ans = 0
for i in range(N):
    ans+=l//A[i]
     
print(ans%mod)
# Judge status: Wrong Answer
n = int(input())
A = [int(x) - int(i) for i, x in enumerate(input().split(), 1)]
b = sum(A)//n
res1 = 0
for a in A:
  res1 += abs(a - b)
b += 1
res2 = 0
for a in A:
  res2 += abs(a - b)
print(min(res1, res2))
# Judge status: Accepted
H, W, N = int(input()), int(input()), int(input())
print((N+max(H, W)-1)//max(H, W))
# Judge status: Accepted
from heapq import *
n,m = map(int,input().split())
a = list(map(int,input().split()))

heap = []
for i in a:
    heappush(heap,-i)

for _ in range(m):
    tmp = heappop(heap)
    heappush(heap,-(-tmp//2))

ans = 0
for a in heap:
    ans += -a 
print(ans)
# Judge status: Accepted
n = int(input())
lsa = list(map(int,input().split()))
lsb = list(map(int,input().split()))
p = 0
t = []
for i in range(n):
    if i ==0:
        p += sum(lsb) + lsa[0]
        t.append(p)
        p = 0
    else:
        p += sum(lsa[:i+1]) + sum(lsb[i:])
        t.append(p)
        p = 0
print(max(t))
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int, input().split())) for _ in range(m)]

sorted_ab=sorted(bc, reverse=True, key=lambda x: x[1])
new_ab=[]
ans=[]

for i in range(m):
    if len(new_ab)<=n:
        tmp_l=[sorted_ab[i][1]]*sorted_ab[i][0]
        new_ab+=tmp_l
    else:
        break

final_list=a+new_ab
final_list.sort(reverse=True)
print(sum(final_list[:n]))
# Judge status: Accepted
n, a, b= map(int, input().split())
ALlsum = 0

for i in range(1, n+1):
    sum = 0
    i = str(i)
    i_len = len(i)
    for j in range(i_len):
        sum += int(i[j])
    if a<=sum and sum<=b :
        ALlsum += int(i)


print(ALlsum)
# Judge status: Accepted
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z=[]
for i in range(X+1,Y+1):
    if max(x)<i and min(y)>=i:
        z.append(i)
if len(z)>=1:
    print('No War')
else:
    print('War')
# Judge status: Accepted
S, T = map(str,input().split())

print(T+S)
# Judge status: Accepted
N, H = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A, B = [], []
for a, b in AB:
  A.append(a)
  B.append(b)

maxA = max(A)
B_stack = []
for b in B:
  if b > maxA:
    B_stack.append(b)
B_stack.sort()
B_stack = B_stack[::-1]

answer = 0
for b in B_stack:
  H -= b
  answer += 1
  if H <= 0:
    print(answer)
    exit()

answer += -(-H // maxA)
print(answer)
# Judge status: Wrong Answer
N=int(input())
odd=0

for i in range(1,N+1):
  if i%2==0:
    odd+=1
    
print(odd/N)
# Judge status: Accepted
import fractions


n,X= map(int,input().split())
x = list(map(int, input().split()))
x.append(X)
x = sorted(x)

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = x[i+1] - x[i]

ans = difflis[0]
for i in range(1,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(ans)
# Judge status: Wrong Answer
number = int(input())

integers = list(map(int, input().split(" ")))

counter = 0

while True:
  if integers[0]%2 == 0 \
  and integers[1]%2 == 0 \
  and integers[2]%2 == 0:
    counter += 1
    integers = [pivot/2 for pivot in integers]
  else:
    break

print(counter)
# Judge status: Wrong Answer
S = input()
T = input()

min_count = 10000000

for k in range(len(T)):
  for i in range(len(S)-len(T)+1):
    count = k
    if T[k] == S[k+i]:
      for j in range(1,len(T)-k):
        if S[i+j] != T[k+j]:
          count += 1
      if count < min_count:
        min_count = count
        
print(min_count)