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

from functools import reduce

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


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

b = list(set(a))
# for i in range(n):

# L = reduce(lcm, a)
L = reduce(lcm, b)

# print(L)

for i in range(n):
    ans += (L // a[i])
    # ans %= mod

print(ans % mod)

### FIXED CODE ###

from functools import reduce

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


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

def modinv(x):
    return pow(x, mod-2, mod)

b = list(set(a))
# for i in range(n):

# L = reduce(lcm, a)
L = reduce(lcm, b)

# print(L)

for i in range(n):
    # ans += (L // a[i])
    ans += L * modinv(a[i])

print(ans % mod)
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
ans=0
for i in range(3001):
    for j in range(3001):
        if n-(r*i+g*j)>=0 and (n-(r*i+g*j))%b==0:
            ans+=1
print(ans)

### FIXED CODE ###

r, g, b, n = map(int, input().split())
ans=0
for i in range(n//r+1):
    for j in range(n-r*i+1):
        p=n-(r*i+g*j)
        if p>=0 and p%b==0:
            ans+=1
print(ans)
### BUGGY CODE ###

def main():
  N, K, C=map(int, input().split())
  S = input()[::-1]
  
  R=[0]*K
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      R[k]=(N-n)
      k+=1
      n += C
    n+=1
  
  S=S[::-1]
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 in R:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  
if __name__=='__main__':
  main()


### FIXED CODE ###

def main():
  N, K, C=map(int, input().split())
  S = input()

  R=[0]*K
  n, k=N-1, 0
  while k < K:
    if S[n]=='o':
      R[k]=n+1
      k+=1
      n -= C
    n-=1
  R=R[::-1]
  
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 == R[k]:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  

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

# -*- coding:utf-8 -*-
import sys

N = int(input())
Sn = sorted([int(input()) for i in range(N)])
total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()
else:
    i = 0
    while True:
        total -= Sn[i]
        if total % 10 != 0:
            print(total)
            sys.exit()

print(0)

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys

N = int(input())
Sn = sorted([int(input()) for i in range(N)])
total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()
else:
    i = 0
    while True:
        if (total - Sn[i]) % 10 != 0:
            print(total - Sn[i])
            sys.exit()
        i += 1
        if i == N:
            break
print(0)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import io
import sys
import math
from functools import lru_cache

@lru_cache(maxsize=None)
def solve(s,l,r):
    # implement process
    str = s[l-1:r]
    return str.count("AC")

def main():
    # input
    n,q = map(int, input().split())
    s = input()
    
    # process
    ans = ""
    for _ in range(q):
        l,r = map(int, input().split())
        ans += str( solve(s,l,r) ) + "\n"
         
    # output    
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
8 3
ACACTACG
3 7
2 3
1 8
"""
_EXPECTED = """\
2
0
3

"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

### FIXED CODE ###

# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(ac_lst,l,r):
    # implement process
    #l=2,r=3
    if l == 1:
        return ac_lst[r-2]
    return ac_lst[r-2] - ac_lst[l-2]
    

def make_ac_lst(s):
    ac_lst = [0] * len(s)
    for i in range(len(s)-1):
        if i != 0:
            ac_lst[i] += ac_lst[i-1]
        if s[i] == "A" and s[i+1] == "C":
            ac_lst[i] += 1
    ac_lst[-1] = ac_lst[-2]

    if _DEB: logd(f"{ac_lst}")
    return ac_lst

def main():
    # input
    n,q = map(int, input().split())
    s = input()
    
    # process
    ans = ""
    ac_lst = make_ac_lst(s)

    for _ in range(q):
        l,r = map(int, input().split())
        ans += str( solve(ac_lst,l,r) ) + "\n"
         
    # output    
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
8 3
ACACTAAC
7 8
2 3
1 8
"""
_EXPECTED = """\
2
0
3

"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")
### BUGGY CODE ###

import heapq
from operator import itemgetter
n, m = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
BC = sorted([ list(map(int, input().split())) for _ in range(m) ], key=itemgetter(1))
for i in range(m):
  b, c = BC[i]
  for _ in range(b):
    t = heapq.heappop(A)
    heapq.heappush(A, max(c, t))
print(sum(A))

### FIXED CODE ###

from operator import itemgetter
n, m = map(int, input().split())
A = [(1, i) for i in map(int, input().split())]
BC = [ tuple(map(int, input().split())) for _ in range(m) ]
XY = sorted(A + BC, reverse=True, key=itemgetter(1))
c = n
now = 0
ans = 0
while c > 0 and now < n+m:
  x, y = XY[now]
  t = min(c, x)
  ans += y*t
  c -= t
  now += 1
print(ans)
### BUGGY CODE ###

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

# a = set()
# for i in range(m):
#     a_tmp = int(input())
#     a.add(a_tmp)

a = [int(input()) for i in range(m)]

dp = [0] * (n + 1)
for i in range(n + 1):
    if i in a:
        dp[i] = 0
    else:
        if i == 0:
            dp[i] = 1
        elif i == 1:
            dp[i] = 1
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
A = set()
for i in range(m):
    a = int(input())
    A.add(a)
dp = [0] * (n + 1)
for i in range(n + 1):
    if i in A:
        dp[i] = 0
    else:
        if i == 0:
            dp[i] = 1
        elif i == 1:
            dp[i] = 1
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])

"""
100 5
1
23
45
67
89
"""
### BUGGY CODE ###


from collections import deque
# 縦(H)x横(W)
H, W = map(int, input().split())
# 魔法使いの座標
CH, CW = map(int, input().split())
# ゴール
DH, DW = map(int, input().split())
# マップ
S = [list(input()) for _ in range(H)]
# 移動Aの動き方
move_a = [(0, 1), (0, -1), (1, 0), (-1, 0)]
# 移動Bの動き方
move_b = [(x, y) for x in range(-2, 3)
          for y in range(-2, 3) if (x, y) not in move_a + [(0, 0)]]

# 各マスへの移動コスト
path = [[10**10] * W for _ in range(H)]

q = deque()
path[CH-1][CW-1] = 0
q.append((CH-1, CW-1, 0))

while q:

    x, y, s = q.popleft()

    # 移動Aについて
    for dx, dy in move_a:
        nx = x + dx
        ny = y + dy

        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))

    # 移動Bについて
        for dx, dy in move_b:
            nx = x + dx
            ny = y + dy

            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and path[nx][ny] > s+1:
                path[nx][ny] = s+1
                q.append((nx, ny, s+1))


print(path[DH-1][DW-1]) if path[DH-1][DW-1] < 10 ** 10 else print(-1)


### FIXED CODE ###

from collections import deque
# 縦(H)x横(W)
H, W = map(int, input().split())
# 魔法使いの座標
CH, CW = map(int, input().split())
# ゴール
DH, DW = map(int, input().split())
# マップ
S = [list(input()) for _ in range(H)]
# 移動Aの動き方
move_a = [(0, 1), (0, -1), (1, 0), (-1, 0)]
# 移動Bの動き方
move_b = [(x, y) for x in range(-2, 3)
          for y in range(-2, 3) if (x, y) not in move_a + [(0, 0)]]

INF = 10 ** 10
# 各マスへの移動コスト
path = [[INF] * W for _ in range(H)]

q = deque()
path[CH-1][CW-1] = 0
q.append((CH-1, CW-1, 0))

while q:

    x, y, s = q.popleft()

    # 移動Aについて
    for dx, dy in move_a:
        nx = x + dx
        ny = y + dy

        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))

# 移動Bについて
    for dx, dy in move_b:
        nx = x + dx
        ny = y + dy

        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and path[nx][ny] > s+1:
            path[nx][ny] = s+1
            q.append((nx, ny, s+1))


print(path[DH-1][DW-1]) if path[DH-1][DW-1] < INF else print(-1)
### BUGGY CODE ###

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

    for _ in range(M):
        b, c = [int(i) for i in input().split()]
        A += [c] * b

    A.sort()
    print(sum(A[-N:]))



if __name__ == "__main__":
    main()

### FIXED CODE ###

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

    A.sort()


    bc = [[int(i) for i in input().split()] for _ in range(M)]
    bc.sort(key=lambda x: x[1])


    ai = N - 1
    mi = M - 1
    pos = 0
    ans = 0
    for _ in range(N):
        if (A[ai] > bc[mi][1]) | (mi < 0):
            pos += 1
            ans += A[ai]
            ai -= 1
        elif pos + bc[mi][0] >= N:
            ans += bc[mi][1] * (N - pos)
            break
        else:
            ans += bc[mi][0] * bc[mi][1]
            pos += bc[mi][0]
            mi -= 1
        if pos >= N:
            break

    print(ans)



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

import sys
sys.setrecursionlimit(1000000)
s = input()
t = input()
dp = [[-1] * (len(t) + 1) for _ in range(len(s) + 1)]
dp[0][0] = 0
def rec(i, j):
  if dp[i][j] != -1:
    return dp[i][j]
  k = -1
  if i - 1 >= 0:
    k = rec(i - 1, j)
  if j - 1 >= 0:
    k = max(k, rec(i, j - 1))
  if i - 1 >= 0 and j - 1 >= 0 and s[i - 1] == t[j - 1]:
    k = max(k, rec(i - 1, j - 1) + 1)
  dp[i][j] = k
  return dp[i][j]
rec(len(s), len(t))
i = len(s)
j = len(t)
result = ''
while i > 0 and j > 0:
  if dp[i - 1][j] == dp[i][j]:
    i -= 1
  elif dp[i][j - 1] == dp[i][j]:
    j -= 1
  else:
    result = s[i - 1] + result
    i -= 1
    j -= 1
print(result)

### FIXED CODE ###

s = input()
t = input()
slen = len(s)
tlen = len(t)
dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
for i in range(slen):
  for j in range(tlen):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
result = ''
i = slen
j = tlen
while i > 0 and j > 0:
  if dp[i - 1][j] == dp[i][j]:
    i -= 1
  elif dp[i][j - 1] == dp[i][j]:
    j -= 1
  else:
    result = s[i - 1] + result
    i -= 1
    j -= 1
print(result)
### BUGGY CODE ###

import math
from collections import defaultdict
from collections import deque


class UnionFindTree:
    '''
    Union Find Tree
    '''

    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


_ncr = {}


def ncr(n, r):
    if n < r:
        return 0
    k = "{}:{}".format(n, r)
    if k not in _ncr:
        _ncr[k] = math.factorial(n) // (math.factorial(n - r) *
                                        math.factorial(r))
    return _ncr[k]


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

utf = UnionFindTree()
for n in range(1, N + 1):
    utf.make(n)

h = {}
ans = deque([])
total = ncr(N, 2)
now = 0
for i in range(M):
    ans.appendleft(total)

    a, b = ab[M - i - 1]
    x, y = utf.find(a), utf.find(b)
    a = utf.unite(x, y)
    if x != y:
        nx, ny = h.get(x, 1), h.get(y, 1)
        n = nx + ny
        total += ncr(nx, 2) + ncr(ny, 2)
        total -= ncr(n, 2)

        h[x] = 1
        h[y] = 1
        h[a] = n

for v in ans:
    print(v)

### FIXED CODE ###

from collections import defaultdict
from collections import deque


class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


def nc2(n):
    return (n * (n - 1)) >> 1


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

utf = UnionFindTree()
for n in range(1, N + 1):
    utf.make(n)

h = {}
ans = deque([])
total = nc2(N)
now = 0
for i in range(M):
    ans.appendleft(total)

    a, b = ab[M - i - 1]
    x, y = utf.find(a), utf.find(b)
    a = utf.unite(x, y)
    if x != y:
        nx, ny = h.get(x, 1), h.get(y, 1)
        n = nx + ny
        total += nc2(nx) + nc2(ny)
        total -= nc2(n)

        h[x] = 1
        h[y] = 1
        h[a] = n

for v in ans:
    print(v)
### BUGGY CODE ###

x,k,d=map(int,input().split())
m=0
p=0
eo=k
ans=x
for i in range(1,k+1):
  m,p=abs(ans-d),abs(ans+d)
  ans=min(m,p)
  if ans<=d:
    eo=i
    break
if (k-eo)%2==0 and eo<k:
  print(ans)
elif (k-eo)%2==1 and eo<k:
  print(abs(ans-d))
else:
   print(ans)

### FIXED CODE ###

x,k,d=map(int,input().split())
if abs(x)-k*d>=0:
  print(abs(x)-k*d)
else:
  xx,kk=abs(x)-d*(abs(x)//d),k-(abs(x)//d)
  if kk%2==0:
    print(abs(xx))
  else:
    print(abs(xx-d))
### BUGGY CODE ###

N, Q = map(int, input().rstrip().split())
S = [i for i in input()]

for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        S[i], S[i+1] = 2, -1
    else:
        if type(S[i]) != int:
            S[i] = 0

if type(S[-1]) == str:
    S[-1] = 0

list_lr = [map(int, input().rstrip().split()) for i in range(Q)]

for i in list_lr:
    l, r = i
    s = S[l-1:r]
    if s[0] == -1 and s[-1] == 2:
        ans = sum(s)-1
    elif s[0] == -1 and (s[-1] == -1 or s[-1] == 0):
        ans = sum(s)+1
    elif s[-1] == 2 and (s[0] == 2 or s[1] == 0):
        ans = sum(s)-2
    else:
        ans = sum(s)

    print(int(ans))


### FIXED CODE ###

N, Q = map(int, input().rstrip().split())
S = [i for i in input()]

list_lr = [list(map(int, input().rstrip().split())) for i in range(Q)]

t = [0]
ct = 0
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ct += 1
    t.append(ct)

for i in list_lr:
    l, r = i[0], i[1]
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

import sys
from math import sqrt

input = sys.stdin.readline


def I():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    _ = I()
    a_list = MI()

    min = inf
    for a in a_list:
        c = 0
        while a % 2 == 0:
            c += 1

        if min > c:
            min = c

    print(min)
    pass


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from math import sqrt

input = sys.stdin.readline


def I():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    _ = I()
    a_list = MI()

    min = inf
    for a in a_list:
        c = 0
        while a % 2 == 0 and c < min:
            c += 1
            a /= 2

        if min > c:
            min = c

    print(min)
    pass


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

#python3
INF = int(1e9)

def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    s = [0]
    for i in range(n):
        s.append(s[i]+a[i])
    #Xより大きい要素の数を数える
    def counter(x):
        count = 0
        for i in range(n):
            l = -1
            r = n
            while r-l>1:
                mid = (l+r)//2
                if a[i] + a[mid] > x:
                    r = mid
                else:
                    l = mid
            count += n-r
        return count
    
    #Xより大きい要素数がm個未満であるXのうち最大のものを探す
    l = 0 
    r = INF
    while r-l>1:
        mid = (l+r)//2
        if counter(mid) < m:
            r = mid
        else:
            l = mid

    #lより大きい要素の総和を求める 
    def sigma(x):
        cnt = 0
        sgm = 0
        for i in range(n):
            l = -1
            r = n
            while r-l >1:
                mid = (l+r)//2
                if a[i]+a[mid]>x:
                    r = mid
                else:
                    l = mid
            cnt += n-r
            sgm += a[i] * (n-r) + (s[n]-s[r])
        return (sgm, cnt)

    sgm, cnt = sigma(l)
    ans = sgm+(m-cnt)*r
    print(ans)
main()

### FIXED CODE ###

#python3
from bisect import bisect_left
INF = int(1e9)

def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    ac = [0]
    for i in range(n):
        ac.append(ac[i]+a[i])

    def chk(x):
        cnt = 0
        for i in range(n):
            pos = bisect_left(a, x - a[i])
            cnt += (n-pos)
        return (cnt < m)

    l = 0
    r = INF
    while r-l > 1: 
        mid = (l + r)//2
        if chk(mid):
            r = mid
        else:
            l = mid

    cnt = 0
    sgm = 0
    for i in range(n):
        pos = bisect_left(a, r - a[i])
        cnt += (n-pos) 
        sgm += a[i] * (n-pos) + (ac[n] - ac[pos]) 

    print(sgm+(m-cnt)*l)
main()
### BUGGY CODE ###

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

amax = M // N
for i in range(amax, 0, -1):
    if (M - (i * N)) % i == 0:
        ans = i
        break

print(ans)

### FIXED CODE ###

import math

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

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []

for i in L[::-1]:
    # if (M - (N * i)) % i == 0:
    if M % i == 0:
        ans.append(i)

print(max(ans))
### BUGGY CODE ###

power = 1 
n=int(input())
for i in range(1,n+1):
    power *= i
a = 10**9 + 7
print(power%a)

### FIXED CODE ###

import math
n=int(input())
power = math.factorial(n)
print(power%(10**9 + 7))
### BUGGY CODE ###

mod = 10 ** 9 + 7

S = input()
N = len(S)

ans = 0
cnt = 0
length = N - 1
for s in S:
    if s == '1':
        ans += pow(2, cnt, mod) * pow(3, length)
        ans %= mod
        cnt += 1
    length -= 1
ans += pow(2, cnt, mod)
ans %= mod

print(ans)


### FIXED CODE ###

mod = 10 ** 9 + 7

S = input()
N = len(S)

ans = 0
cnt = 0
length = N - 1
for s in S:
    if s == '1':
        ans += pow(2, cnt, mod) * pow(3, length, mod)
        ans %= mod
        cnt += 1
    length -= 1
ans += pow(2, cnt, mod)
ans %= mod

print(ans)
### BUGGY CODE ###

N = int(input())
rules = [int(input()) for _ in range(5)]
mini = min(rules)

# 都市2 以降の合計移動時間で初期化
time = 4

while N > 0:
    N -= mini
    time += 1

print(time)

### FIXED CODE ###

import math
import sys
input=sys.stdin.readline

N = int(input())
# ボトルネックとなる制限人数を取得
mini = min([int(input()) for _ in range(5)])

print(math.ceil(N/mini)+4)
### BUGGY CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def resolve():
    readline=sys.stdin.readline
    mod=10**9+7
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    binArr = [[0 for i in range(60)] for j in range(n)]
    cnt=[0]*60
    for i in range(n):
        b = bin(arr[i])[2:]
        lenb = len(b)
        for j in range(lenb):
            binArr[i][j] = int(b[lenb-1-j])
            cnt[j]+=binArr[i][j]
    ans=[0]*60
    answer = 0
    for i in range(n):
        for j in range(60):
            # 1: cnt[j]
            # 0: n-cnt[j]
            cnt[j]-=binArr[i][j]
            if binArr[i][j] == 0:
                ans[j] += cnt[j]
            else:
                ans[j] += (n-cnt[j]-i-1)
    x=1
    for i in range(60):
        answer += ans[i]*x
        answer %= mod
        x*=2
        x%=mod
    print(answer)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

### FIXED CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def resolve():
    readline=sys.stdin.readline
    mod=10**9+7
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    binArr = [[0 for i in range(60)] for j in range(n)]
    cnt=[0]*60
    for i in range(n):
        b = bin(arr[i])[2:]
        lenb = len(b)
        for j in range(lenb):
            binArr[i][j] = int(b[lenb-1-j])
            cnt[j]+=binArr[i][j]
    ans=[0]*60
    answer = 0
    for i in range(n):
        for j in range(60):
            # 1: cnt[j]
            # 0: n-cnt[j]
            cnt[j]-=binArr[i][j]
            if binArr[i][j] == 0:
                ans[j] += cnt[j]
            else:
                ans[j] += (n-cnt[j]-i-1)
    x=1
    for i in range(60):
        answer += ans[i]*x
        answer %= mod
        x*=2
        x%=mod
    print(answer)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------