Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                for z in range(k+1):
                        if x + y + z == s:
                                ans += 1
print(ans)




### FIXED CODE ###

import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

k, s = na()
ans = 0
for x in range(k+1):
        for y in range(k+1):
                z = s - x - y
                if z <= k and z >= 0:
                        ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

import sys
sys.setrecursionlimit(10**8)

mod = 10**9+7
def dfs(v):
    white,black = 1,1
    for u in edge[v]:
        if visited[u]==False:
            visited[u]=True
            w,b = dfs(u)
            white *= w+b
            white %= mod
            black *= w
            black %= mod
    return white,black

visited = [False]*N
visited[0]=True
print(sum(dfs(0))%mod)

### FIXED CODE ###

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

import sys
sys.setrecursionlimit(10**8)

mod = 10**9+7
def dfs(v):
    white,black = 1,1
    for u in edge[v]:
        if visited[u]==False:
            visited[u]=True
            w,b = dfs(u)
            white *= w+b
            white %= mod
            black *= w
            black %= mod
    return white,black

visited = [False]*N
visited[0]=True
print(sum(dfs(0))%mod)
### BUGGY CODE ###

a,b,c = map(int, input().split())
 
for i in range(c):
  if(a == 0 and b > 0):
  	b -= 1
  elif(a > 0):
    a -= 1
print(str(a),str(b))

### FIXED CODE ###

a,b,c = map(int, input().split())
 
print(max(0,a-c),max(0, b - max(0,c-a)))
### BUGGY CODE ###

n=int(input())
ans=0
for i in range(1,n+1):
  sa=list(str(i))
  nums=map(int,sa)
  sumj=sum(nums)
  
  ans=max(ans,sumj)
print(ans)

### FIXED CODE ###

n=str(input())
cn=sum(map(int,list(n)))

k=len(n)
c=int(n[0])
n=int(n)
if cn==(c+9*(k-1)):
  print(c+9*(k-1))
else:
  print(c+9*(k-1)-1)
### BUGGY CODE ###

import heapq
from itertools import accumulate

n,m,s,t = map(int,input().split())
inf = 1000000000000000
gyen = [[] for _ in range(n)]
gsnuk = [[] for _ in range(n)]

for _ in range(m):
        u,v,a,b = map(int,input().split())
        gyen[u-1].append([v-1,a])
        gyen[v-1].append([u-1,a])
        gsnuk[u-1].append([v-1,b])
        gsnuk[v-1].append([u-1,b])

def dijkstra(graph, start):
        dist = [inf for _ in range(n)]
        dist[start] = 0
        q = [(0,start)]
        rem = n-1
        while q and rem>0:
                du, u = heapq.heappop(q)
                if dist[u] < du:
                        continue
                rem -= 1
                for i in graph[u]:
                        if dist[i[0]] > du+i[1]:
                                dist[i[0]] = du+i[1]
                                heapq.heappush(q, (dist[i[0]], i[0]))
        return dist

yen = dijkstra(gyen,s-1)
snuke = dijkstra(gsnuk,t-1)

ans = list(accumulate([y+s for y,s in zip(yen,snuke)][::-1],min))
[print(inf-ans[i]) for i in range(n-1,-1,-1)]

### FIXED CODE ###

import heapq
import sys
from itertools import accumulate

n,m,s,t = map(int,next(sys.stdin).split(" "))
inf = 1000000000000000
gyen = [dict() for _ in range(n)]
gsnuk = [dict() for _ in range(n)]

for _ in range(m):
        u,v,a,b = map(int,next(sys.stdin).split(" "))
        gyen[u-1][v-1] = gyen[v-1][u-1] = a
        gsnuk[u-1][v-1] = gsnuk[v-1][u-1] = b

def dijkstra(graph, start):
        dist = [inf for _ in range(n)]
        dist[start] = 0
        q = [(0,start)]
        while q:
                du, u = heapq.heappop(q)
                if dist[u] < du:
                        continue
                for v,d in graph[u].items():
                        if dist[v] > du+d:
                                dist[v] = du+d
                                heapq.heappush(q, (dist[v], v))
        return dist

yen = dijkstra(gyen,s-1)
snuke = dijkstra(gsnuk,t-1)

ans = list(accumulate([y+s for y,s in zip(yen,snuke)][::-1],min))
[print(inf-ans[i]) for i in range(n-1,-1,-1)]
### BUGGY CODE ###

S = input()
T = input()

def trans(c1, c2):
  tmp = ","
  return S.replace(c1, tmp).replace(c2, c1).replace(tmp, c2)

for i in range(len(S)):
  if S[i] != T[i]:
    S = trans(S[i], T[i])
if S == T:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
T = input()

R = {chr(i) : -1 for i in range(97, 97 + 26)}
Rd = {chr(i) : -1 for i in range(97, 97 + 26)}

def check(i):
  ret = True
  if R[S[i]] >= 0 and R[S[i]] != ord(T[i]):
    ret = False
  if Rd[T[i]] >= 0 and Rd[T[i]] != ord(S[i]):
    ret = False
  if R[S[i]] < 0:
    R[S[i]] = ord(T[i])
  if Rd[T[i]] < 0:
    Rd[T[i]] = ord(S[i])
  return ret

ans = "Yes"
for i in range(len(S)):
  if not check(i):
    ans = "No"
    break
print(ans)
### BUGGY CODE ###

H,W = map(int,input().split())
A = [input() for _ in range(H)]
ans = [[3000]*(W+2) for _ in range(H+2)]
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            ans[i+1][j+1] = 0

for x in range(H+W+1):
    for i in range(H):
        for j in range(W):
            ans[i+1][j+1] =min(min(ans[i+1][j],ans[i+1][j+2],ans[i][j+1],ans[i+2][j+1])+1,ans[i+1][j+1])

num = 0
for i in range(H):
    for j in range(W):
        num = max(num,ans[i+1][j+1])

print(num)

### FIXED CODE ###

H,W = map(int,input().split())
A = [input() for _ in range(H)]
ans = [[10000]*(W+2) for _ in range(H+2)]
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            ans[i+1][j+1] = 0

for i in range(H):
    for j in range(W):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+1][j]+1)
for i in range(H):
    for j in range(W-1,-1,-1):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+1][j+2]+1)
for j in range(W):
    for i in range(H):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i][j+1]+1)
for j in range(W):
    for i in range(H-1,-1,-1):
        ans[i+1][j+1] = min(ans[i+1][j+1],ans[i+2][j+1]+1)

num = 0
for i in range(H):
    for j in range(W):
        num = max(num,ans[i+1][j+1])

print(num)
### BUGGY CODE ###

n = int(input().rstrip())

def calc(target):
    excess = set()
    result = 0
    count = 0
    if target % 2 == 0:
        return -1
        
    while True:
        count += 1
        result = (result * 10 + 7) % target
        excess.add(result)
        if result == 0:
            break
    
    return count
    
print(calc(n))

### FIXED CODE ###

n = int(input().rstrip())

def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
    
calc(n)
### BUGGY CODE ###

import sys
from scipy.sparse import*
g=[]
n=int(sys.stdin.readline())
for _ in xrange(n-1):
	a,b=map(int,sys.stdin.readline().split())
	g.append((a-1,b-1,1))
z=[-1]*n
for _ in xrange(int(sys.stdin.readline())):
	a,b=map(int,sys.stdin.readline().split())
	g.append((n,a-1,b))
	z[a-1]=b
a,b,c=zip(*g)
a=map(int,csgraph.dijkstra(csr_matrix((c,(a,b)),[n+1]*2),0,n))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		exit()
for e in g:
	if e[0]<e[1] and abs(a[e[0]]-a[e[1]])!=1:
		print('No')
		exit()
print('Yes')
print("\n".join(map(str,a[:n])))

### FIXED CODE ###

#!/usr/bin/python
def shortestPath(g,s,dist,prev):
	n = len(g)-1
	Q=[]
	heapq.heappush(Q,(0,-2,s))
	while Q:
		e = heapq.heappop(Q)
		if prev[e[2]]!=-1: continue
		prev[e[2]] = e[1]
		for f in g[e[2]]:
			if dist[f[2]] > e[0] + f[0]:
				dist[f[2]] = e[0] + f[0]
				heapq.heappush(Q,(e[0]+f[0],f[1],f[2]))

import sys,heapq
#if sys.version_info[0]>=3:raw_input=input

n=int(raw_input())
g=[[] for _ in range(n+1)]
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g[a-1]+=[(1,a-1,b-1)]
	g[b-1]+=[(1,b-1,a-1)]
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g[n]+=[(b,n,a-1)]
	z[a-1]=b
a=[1e9]*n+[0]
shortestPath(g,n,a,[-1]*(n+1))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		sys.exit()
for _ in g:
	for e in _:
		if e[1]<e[2] and abs(a[e[1]]-a[e[2]])!=1:
			print('No')
			sys.exit()
print('Yes')
print("\n".join(map(str,a[:n])))
### BUGGY CODE ###

S=input()
L=len(S)
s=[1]*L
l=[s]
def k(s):
    t=[0]*L
    for i in range(L):
        if S[i]=="R":
            t[i+1]+=s[i]
        else:
            t[i-1]+=s[i]
    return(t)
while 1:
    l.append(k(s))
    for i in range(len(l)-1):
        if l[-1]==l[i]:
            a=len(l)-1-i
            d=i
            break
    else:
        s=l[-1]
        continue
    break
A=l[(10**100-d)%a+d]
for i in A:
    print(i,end=" ")

### FIXED CODE ###

S=input()
L=len(S)
l=[0]*L
b=0
while 1:
    t=1
    while 1:
        b+=1
        if S[b]=="R":
            t+=1
        else:
            break
    l[b]+=t//2
    l[b-1]+=t-t//2
    t=1
    while 1:
        if b==L-1:
            b+=1
            break
        b+=1
        if S[b]=="L":
            t+=1
        else:
            break
    l[b-t-1]+=t//2
    l[b-t]+=-(-t//2)
    if b==L:
        break
for i in l:
    print(i,end=" ")
### BUGGY CODE ###

S = input()[:: -1]
mod = 10 ** 9 + 7
dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]

if S[0] == "?":
    for k in range(10):
        dp[1][k % 13] += 1
else:
    dp[1][int(S[0]) % 13] += 1

for i in range(2, len(S) + 1):
    for j in range(13):
        if S[i - 1] == "?":
            for k in range(10):
                dp[i][(10 ** (i - 1) * k + j) % 13] += dp[i - 1][j] % mod
        else:
            dp[i][(10 ** (i - 1) * int(S[i - 1]) + j) % 13] += dp[i - 1][j] % mod

print(dp[len(S)][5] % mod)

### FIXED CODE ###

S = input()[:: -1]
mod = 10 ** 9 + 7
dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]

if S[0] == "?":
    for k in range(10):
        dp[1][k % 13] += 1
else:
    dp[1][int(S[0]) % 13] += 1

tmp = 1
for i in range(2, len(S) + 1):
    tmp *= 10
    tmp %= 13
    for j in range(13):
        if dp[i - 1][j] > 0:
            if S[i - 1] == "?":
                for k in range(10):
                    dp[i][(tmp * k + j) % 13] += dp[i - 1][j] % mod
            else:
                dp[i][(tmp * int(S[i - 1]) + j) % 13] += dp[i - 1][j] % mod

print(dp[len(S)][5] % mod)
### BUGGY CODE ###

n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
ll=l[:]
for j in range(len(l)):
    l=ll[:]
    l.pop(j)
    print(max(l))


### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
m=sorted(l)
m1=m[-1]
m2=m[-2]
c=l.count(m1)

for j in l:
    if j==m1:
        if c>1:
            print(m1)
        else:
            print(m2)
    else:
        print(m1)
### BUGGY CODE ###

x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  insort(p_list,  int(value))

for value in input().split():
  insort(q_list,  int(value))
  
for value in input().split():
  insort(r_list,  int(value))
  
red = 0
green = 0
white = 0

sum_num = 0
for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1
    
print(sum_num)

### FIXED CODE ###

x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)
### BUGGY CODE ###

from collections import defaultdict
n = int(input())
r = []
dead = defaultdict(int)
for i in range(n):
    x, l = map(int, input().split())
    r.append((x - l + 1, x + l - 1))
    for d in range(x - l + 1, x + l):
        dead[d] += 1
while max(dead.values()) > 1:
    maxi, maxd = 0, 0
    for i, ri in enumerate(r):
        dd = sum([dead[d] for d in range(ri[0], ri[1] + 1)])
        if dd > maxd:
            maxi = i
            maxd = dd
    for d in range(r[maxi][0], r[maxi][1] + 1):
        dead[d] -= 1
    n -= 1
print(n)

### FIXED CODE ###

n = int(input())
r = []
for i in range(n):
    x, l = map(int, input().split())
    r.append((x - l, x + l))
r.sort(key=lambda _x: _x[1])
cnt = 1
limit = r[0][1]
for ri in r[1:]:
    if ri[0] >= limit:
        cnt += 1
        limit = ri[1]
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

dp = [10 ** 9 for _ in range(H + 1)]
dp[0] = 0

for i in range(1, H + 1):
    for j in range(N):
        A = A_list[j]
        B = B_list[j]
        dp[i] = min(dp[i], (dp[i - A] if i >= A else 0) + B)

print(dp[-1])

### FIXED CODE ###

# E
# -*- coding: utf-8 -*-
H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

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

def test_func(dp, A_list, B_list, i, N):
    return(min([(dp[i - A_list[j]] if i >= A_list[j] else 0) + B_list[j] for j in range(N)]))


for i in range(1, H + 1):
    dp[i] = test_func(dp, A_list, B_list, i, N)

print(dp[-1])
### BUGGY CODE ###

n=int(input())

l=10**9+7
numlist=[format(int(i),"060b") for i in input().split(" ")]
# print(numlist)


def xor(a,b):
    c=[]
    for i in range(60):
        if a[i]!=b[i]:
            c.append("1")
        else:
            c.append("0")
    return int("".join(c),2)
        

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=xor(numlist[i],numlist[j])
    ans=ans%l
print(ans)
        

### FIXED CODE ###

#D問題

#ビットごとに考えられる
k=10**9+7

anslist=[]

n=int(input())
a=[format(int(i), '060b') for i in input().split()]
d=[]

for i in range(60):
    b=[j[59-i] for j in a]
    c=b.count("0")*b.count("1")
    d.append(c*2**(i)%k)
ans=0

for i in d:
    ans+=i
print(ans%k)
### BUGGY CODE ###

def main():
    s = input()
    cnt = 0
    tmp = ""

    while tmp != s:
        tmp = s
        cnt += s.count("BW")
        s = s.replace("BW", "WB")
        if tmp == s:
            break

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
x,y,z,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = []
for r in itertools.product(a,b,c):
    ans.append(r[0] + r[1] + r[2])
ans.sort()
for i in range(k):
    print(ans[-i-1])

### FIXED CODE ###

x,y,z,k = map(int, input().split())
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
sumABC = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

for i in range(k):
    print(sumABC[i])
### BUGGY CODE ###

from functools import reduce
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    """
    return gcd of a,b
    ユークリッド
    """
    while b:
        a, b = b, a % b
    return a


def list_gcd(l):
    """
    l: list
    l のgcd を返す
    """
    return reduce(gcd, l)

K = int(input())
ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans+=list_gcd([i,j,k])
print(ans)



### FIXED CODE ###


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    """
    return gcd of a,b
    ユークリッド
    """
    a,b =max(a,b),min(a,b)
    while b:
        a, b = b, a % b
    return a



K = int(input())
ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        i_j = gcd(i,j)
        for k in range(1,K+1):
            ans+=gcd(i_j,k)
print(ans)
### BUGGY CODE ###

import sys
import numpy as np
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N, W = map(int, input().split())
weight_value = [LI() for i in range(N)]


dp = np.zeros([N+1,W+1],dtype=int)

for i in range(N):
    for sum_w in range(W+1):
        if sum_w - weight_value[i][0] >=  0:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight_value[i][0]] + weight_value[i][1])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]

print(dp[N][W])


### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())

dp = np.zeros([N+1,W+1],dtype=int)

# 重かったので却下
# for i in range(N):
#     weight,value = map(int, input().split())
#     for sum_w in range(W+1):
#         if sum_w - weight >=  0:
#             dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight] + value)
#         dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

for i in range(N):
    weight, value = map(int, input().split())
    dp[i+1] = dp[i]
    dp[i+1, weight:] = np.maximum(dp[i+1, weight:], dp[i, :W-weight+1] + value)

print(dp[N][W])
### BUGGY CODE ###

s = input()

flag = 0
#print(len(s))
if(len(s) > 1):
    flag = 1
    s_save = s[1:-1]
    s = s[0]+"123"+s[-1]
 
n = int(input())

for i in range(n):
    que = input()
    if(len(que) == 1):
        s = s[::-1]
    else:
        que = que.split()
        if(que[1]=="1"):
            s = que[2] + s
        else:
            s = s + que[2]


if(flag == 0):
    print(s)
else:
    if("123" in s):
        print(s.replace("123",s_save))
    else:
        print(s.replace("321",s_save[::-1]))



### FIXED CODE ###

s = input()

flag = 0
cnt = 0
n = int(input())

que_ar = [input() for _ in range(n)]

f_x = ["" for _ in range(n)]
b_x = ["" for _ in range(n)]


f = n-1
b = 0

for i in range(n):
    que = que_ar[i]
    if(len(que) == 1):
        cnt += 1
    else:
        que = que.split()
        if(cnt%2 == 0):
            if(que[1]=="1"):
                f_x[f] = que[2]
                f -= 1
            else:
                b_x[b] = que[2]
                b += 1
        else:
            if(que[1]=="1"):
                b_x[b] = que[2]
                b += 1
            else:
                f_x[f] = que[2]
                f -= 1

s = "".join(f_x)+s+"".join(b_x)             
                
if(cnt%2 == 0):
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

import itertools as it

N=int(input())
a_l=[int(i) for i in input().split()]

sum1=0
for (i,j) in it.combinations(a_l, 2):
    l=max(len(str(format(i,'b'))),len(str(format(j,'b'))))
    i2=str(format(i,'b').zfill(l))
    j2=str(format(j,'b').zfill(l))
    for k in range(l):
        if i2[k]!=j2[k]:
            sum1 += 2**(l-k-1)
print(sum1%(7+10**9))

### FIXED CODE ###

n=int(input())
lis=list(map(lambda x:format(int(x),'b'),input().split()))
l=0
for i in range(n):
    l=max(l,len(lis[i]))

d0=[0]*60
d1=[0]*60

for i in range(n):
    lis[i]=lis[i].zfill(l)
    for j in range(l):
        if lis[i][-j-1]=='0':
            d0[j]+=1
        else:
            d1[j]+=1

ans=0
for i in range(60):
    ans+=(d0[i]*d1[i]*2**i)%(10**9+7)
print(ans%(10**9+7))
### BUGGY CODE ###

mod = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
#S[0]は使わない
S = [[0]*60 for _ in range(N)]

tmp = A[-1]
idx = 0
while tmp > 0:
    if tmp%2:
        S[-1][idx] += 1
    idx += 1
    tmp //= 2

for i in range(N-2, 0, -1):
    for j in range(60):
        S[i][j] = S[i+1][j]
    tmp = A[i]
    idx = 0
    while tmp > 0:
        if tmp % 2:
            S[i][idx] += 1
        idx += 1
        tmp //= 2

ans = 0
for i in range(N-1):
    tmp = A[i]
    idx = 0
    while tmp > 0:
        if tmp % 2:
            ans += ((N-1-i)-S[i+1][idx])*2**idx%mod

        else:
            ans += S[i+1][idx]*2**idx%mod

        idx += 1
        tmp //= 2

    rest = S[i+1][idx:]
    for x in rest:
        ans += x*2**idx%mod
        idx += 1

    ans %= mod

print(ans)


### FIXED CODE ###

mod = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(60):
    a = 0
    b = 0
    for j in range(N):
        if A[j] % 2:
            a += 1
        else:
            b += 1
        A[j] //= 2
    ans += a*b*pow(2, i, mod)
    ans %= mod
print(ans)
### BUGGY CODE ###

from collections import defaultdict


N = int(input())
A = list(map(int, input().split())) 
MOD = 10**9 + 7
def primes(num):
    if num == 1:
        d = defaultdict(int)
        d[1] = 1
        return d

    i = 2
    d = defaultdict(int)
    while i * i <= num:
        while num % i == 0:
            num //= i
            d[i] += 1
        i += 1
    if num > 1:
        d[num] += 1

    return d

d = primes(A[0])

for a in A[1:]:
    tmp_d = primes(a)
    dk = set(d.keys())
    tmp_dk = set(tmp_d.keys())
    dk = dk | tmp_dk
    for k in dk:
        d[k] = max(d[k], tmp_d[k])

lcm = 1

for k in d.keys():
    lcm *= k**d[k]


ans = 0
for i in range(N):
    ans += (lcm // A[i])
    ans %= MOD

print(ans)

### FIXED CODE ###

from fractions import gcd


def main():
        
    N = int(input())
    A = list(map(int, input().split())) 
    MOD = 10**9 + 7


    l = 1

    for a in A:
        l = l * a // gcd(l, a)


    ans = 0
    for a in A:
        ans += (l // a)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()