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

n = int(input())
def move(max_num,before):
  return min(max_num,before)

people = [n,0,0,0,0,0]
max_nums = []
for i in range(5):
  max_nums.append(int(input()))

time = 0
while True:
#for j in range(10):
  time += 1
  move_p = [0] * 6
  for i in range(5):
    move_p[i] -= min(max_nums[i],people[i])
    move_p[i+1] += min(max_nums[i],people[i])
  people = list(map(sum,zip(people,move_p)))
  #print(people)
  if people[-1] == n:
    break

print(time)

### FIXED CODE ###

n = int(input())

max_nums = []
for i in range(5):
  max_nums.append(int(input()))
max_nums.append(n)
a = n/min(max_nums)
print(int(a) +4+ (0 if a == int(a) else 1))
### BUGGY CODE ###

from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().rstrip().split()]
    l,r = [int(x) for x in stdin.readline().rstrip().split()]
    ans = set(range(l,r+1))

    for i in range(m-1):
        l,r = [int(x) for x in stdin.readline().rstrip().split()]
        cards = set(range(l,r+1))
        ans = ans & cards

    print(len(ans))
    
if __name__=='__main__':
    main()

### FIXED CODE ###

from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().rstrip().split()]

    _l = 0
    _r = n

    for i in range(m):
        l,r = [int(x) for x in stdin.readline().rstrip().split()]
        _l = max(l, _l)
        _r = min(r, _r)

    if _r - _l < 0:
        print(0)
    else:
        print(_r - _l + 1)
    
if __name__=='__main__':
    main()
### BUGGY CODE ###

p = 10**9+7
L = input().strip()
N = len(L)
C = [0 for _ in range(N)]
for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1]
tot = 0
for i in range(N):
    if L[i]=="1":
        tot = (tot+3**(N-1-i)*2**C[i])%p
if L[N-1]=="0":
    tot = (tot+2**C[N-1])%p
else:
    tot = (tot+2**(C[N-1]+1))%p
print(tot)

### FIXED CODE ###

p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p
L = input().strip()
N = len(L)
C = [0 for _ in range(N)]
for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1]
tot = 0
for i in range(N):
    if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p
if L[N-1]=="0":
    tot = (tot+pow(2,C[N-1]))%p
else:
    tot = (tot+pow(2,C[N-1]+1))%p
print(tot)
### BUGGY CODE ###

n, k = map(int, input().split())
h = [0] + list(map(int, input().split()))
cost = {1: 0, 2: abs(h[2] - h[1])}
for i in range(1, n):
    for di in range(1, k + 1):
        if i + di > n: break
        nc = cost[i] + abs(h[i + di] - h[i])
        if i + di in cost:
            if nc < cost[i + di]:
                cost[i + di] = nc
        else:
            cost[i + di] = nc
print(cost[n])


### FIXED CODE ###

n, k = map(int, input().split())
k = min(n - 1, k)
h = list(map(int, input().split()))
cost = [0 for _ in range(n)]
for i, hi in enumerate(h):
    if i == 0: continue
    st = i - k if i > k else 0
    cost[i] = min([ck + abs(hi - hk) for ck, hk in zip(cost[st:i], h[st:i])])
print(cost[-1])
### BUGGY CODE ###

# D
X, Y, Z, K = map(int, input().split())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

AB_list = [0]*(X*Y)
for i in range(X):
    for j in range(Y):
        AB_list[i*Y+j] = A_list[i] + B_list[j]
AB_list_s = sorted(AB_list)
if len(AB_list_s) > 3000:
    AB_list_s = AB_list_s[-3000:]
W = len(AB_list_s)
ABC_list = [0]*(W*Z)
for i in range(W):
    for j in range(Z):
        ABC_list[i*Z+j] = AB_list_s[i] + C_list[j]
ABC_list_s = sorted(ABC_list)
for i in range(K):
    print(ABC_list_s[-(i+1)])

### FIXED CODE ###

# D
X, Y, Z, K = map(int, input().split())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

AB_list = [0]*(X*Y)
for i in range(X):
    for j in range(Y):
        AB_list[i*Y+j] = A_list[i] + B_list[j]
AB_list_s = sorted(AB_list)
if len(AB_list_s) > 3000:
    AB_list_s = AB_list_s[-3000:]
W = len(AB_list_s)
ABC_list = [0]*(W*Z)
for i in range(W):
    for j in range(Z):
        ABC_list[i*Z+j] = AB_list_s[i] + C_list[j]
ABC_list_s = sorted(ABC_list)
for i in range(K):
    print(ABC_list_s[-(i+1)])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

#%%
def dfs(gr,li,pt,n,fr):
    li[n] += pt
    if(len(gr[n])==1 and gr[n][0]==fr):
        return True
    else:
        for i in gr[n]:
            if(i==fr):continue
            dfs(gr,li,li[n],i,n)
        return True
#%%
def main():
    N,Q = input().split()
    N = int(N)
    Q = int(Q)
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    dfs(gp,li,0,0,-1)
    print(*li)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    st = []
    seen = set()
    st.append(0)
    while(st):
        x = st.pop()
        if(x in seen):continue
        seen.add(x)
        for i in gp[x]:
            if(i in seen):continue
            li[i]+=li[x]
            st.append(i)
    print(*li)

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

if __name__ == "__main__":
	N = int(input())
	counter = 0

	c = 1
	while N - c >= 1:
		i = 1
		while i <= N:
			j = 1
			while i * j <= N:
				if i * j + c== N:
					counter += 1
				j += 1
			i += 1
		c += 1
	print(counter)

### FIXED CODE ###

N = int(input())

ans = 0
for i in range(1,N):
	ans += int((N - 1) / i)
print(ans)
### BUGGY CODE ###

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

dp = [100000000] * (10 ** 5)
dp[0] = 0
for i in range(H):
    if dp[i] == 100000000:
        continue
    for j in range(N):
        a, b = AB[j]
        if dp[i] + b < dp[i + a]:
            dp[i + a] = dp[i] + b
print(min(dp[H:]))


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for j in range(N):
            a, b = AB[j]
            if dp[i] + b < dp[i + a]:
                dp[i + a] = dp[i] + b
    print(min(dp[H:]))


main()
### BUGGY CODE ###

from collections import defaultdict

root = 10000
MOD = 2 ** 61 - 1
def rolling_hash(s):
    hs = [0] * (len(s) + 1)
    for i in range(len(s)):
        hs[i + 1] = hs[i] * root + ord(s[i]) % MOD
    return hs

#"""
N = int(input())
S_list = [input() for _ in range(N)]
"""
def to_alpha(n):
    ret = ''
    while n > 0:
        n -= 1
        ret += chr(n % 26 + ord('a'))
        n //= 26
    return ret

N = 10 ** 5
S_list = [to_alpha(i) for i in range(2, 2 * N + 2, 2)]
#"""


S_list.sort(key=len)

ans = 0
wanted = defaultdict(set)
for S in S_list:
    alpha_set = set()
    hash_of_S = rolling_hash(S)
    for i in range(len(S)):
        alpha_set.add(S[i])
        suffix_hash = (hash_of_S[len(S)] - hash_of_S[i+1] * pow(root, (len(S) - i - 1), MOD)) % MOD
        if suffix_hash in wanted:
            for alpha in wanted[suffix_hash]:
                if alpha in alpha_set:
                    ans += 1

    suffix_of_S = (hash_of_S[len(S)] - hash_of_S[1] * pow(root, (len(S) - 1), MOD)) % MOD
    wanted[suffix_of_S].add(S[0])

print(ans)


### FIXED CODE ###

from collections import defaultdict

root = 10000
MOD = 2 ** 61 - 1


#"""
N = int(input())
S_list = [input() for _ in range(N)]
"""
def to_alpha(n):
    ret = ''
    while n > 0:
        n -= 1
        ret += chr(n % 26 + ord('a'))
        n //= 26
    return ret

N = 2 * 10 ** 5
S_list = [to_alpha(i) for i in range(2, 2 * N + 2, 2)]
#"""


S_list.sort(key=len)

ans = 0
wanted = defaultdict(set)
for S in S_list:
    suffix_hashes = [0]
    for c in S[-1:0:-1]:
        suffix_hashes.append((suffix_hashes[-1] * root + ord(c)) % MOD)
    suffix_hashes.reverse()
    l = len(S)
    alpha_set = set()
    for i, c in enumerate(S):
        alpha_set.add(c)
        # print(alpha_set, suffix_hashes[i])
        if suffix_hashes[i] in wanted:
            for alpha in wanted[suffix_hashes[i]]:
                if alpha in alpha_set:
                    ans += 1
    wanted[suffix_hashes[0]].add(S[0])
        
# print(wanted)
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())  # n:文字数，q:問題数
s = list(input())  # 文字列
l = [list(map(int, input().split())) for _ in range(q)]  # 問題
cnt = [0] * q  # cnt list
for i in range(q):
    list = s[l[i][0] - 1:l[i][1]]  # 考えるリスト
    cnt[i] = 0
    for j in range(len(list) - 1):
        if list[j] == 'A' and list[j + 1] == 'C':
            cnt[i] += 1
for k in range(q):
    print(cnt[k])

### FIXED CODE ###

n, q = map(int, input().split())  # n:num of string，q:num of question
s = input()  # string
cnt = [0] * n  # cnt list of 'AC'

for i in range(n-1):
    if s[i: i + 2] == 'AC':
        cnt[i + 1] += 1

for i in range(1, n):
    cnt[i] += cnt[i - 1]  # 累積和

for i in range(q):
    l, r = map(int, input().split())  # question
    l, r = l - 1, r - 1
    print(cnt[r] - cnt[l])
### BUGGY CODE ###

import math
A,B,N = map(int,input().split())
ans,point = 0,0
for i in range(1,N+1):
    amari = i%B
    Aamari = A*amari
    point = math.floor(Aamari/B)
    ans = max(ans,point)
print(ans)

### FIXED CODE ###

import math
A,B,N = map(int,input().split())
looked = min(B-1,N)
ans = (A*looked)//B - A*(looked//B)
print(ans)
### BUGGY CODE ###

H,N = map(int, input().split())
DP = [0]*(H+1)
dp_ = [0]+[float("inf")]*H
for n in range(N):
  A,B = map(int, input().split())
  dp = list(DP)
  for h in range(1,H+1): dp[h] = min(dp_[h], dp[max(0,h-A)]+B)
  dp_ = dp
print(dp[-1])

### FIXED CODE ###

H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])
### BUGGY CODE ###

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

for i in range(m):
    b,c=map(int,input().split())
    for j in range(b):
        tmp_min = min(an)
        if c > tmp_min:
            an[an.index(tmp_min)] = c
print(sum(an))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
for i in range(M):
    b, c = map(int, input().split())
    D.append((b, c))
A = sorted(A)
D = sorted(D, key=lambda x: x[1], reverse=True)

i = 0
for j in range(M):
    p, q = D[j]
    while p > 0:
        if i < N and q > A[i]:
            A[i] = q
            i += 1
        else:
            break
        p -= 1
print(sum(A))
### BUGGY CODE ###

import sys

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

N,K = LI()
A = LI()

hyoten = [1] * (N-K+1)

for i in range(N-K+1):
    for q in range(K):
        hyoten[i] *= A[i+q]


for j in range(len(hyoten)-1):
    if (hyoten[j+1]>hyoten[j]):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

import sys

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

N,K = LI()
A = LI()

# hyoten = [1] * (N-K+1)

# for i in range(N-K+1):
#     for q in range(K):
#         hyoten[i] *= A[i+q]


# for j in range(len(hyoten)-1):
#     if (hyoten[j+1]>hyoten[j]):
#         print('Yes')
#     else:
#         print('No')

for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

r, g, b, n = map(int,input().split())
count = 0;
for R in range (n+1):
    for G in range (n-R+1):
        for B in range (n-R-G+1):
            if (n == (r*R+g*G+b*B)):
                count = count+1
print(count)

### FIXED CODE ###

R, G, B, N = map(int,input().split())
count = 0
for r in range(N+1):
    for g in range(N+1-r*R):
        b = (N-r*R-g*G)
        if b%B == 0 and b >=0 :
            count+=1
print(count)
### BUGGY CODE ###

n = int(input())
S = []
for i in range(n):
    tmp = "".join(sorted(input()))
    S.append(tmp)
#print(S)
cnt = 0
for s in S:
    #print(S.count(s))
    cnt += (S.count(s)-1)
    S = S[1:]
print(cnt)

### FIXED CODE ###

import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)
### BUGGY CODE ###

import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

""" 
参考:http://drken1215.hatenablog.com/entry/2018/06/08/210000
maximとmodを適宜設定。
あ入力忘れを考慮してあえて入力例通らないようにしておいたで。

combを使う前にcominit()を使う

"""
maxim = 10**7
mod = 10**9+7
fac = [None] * maxim
finv = [None] * maxim
inv = [None] * maxim

def cominit():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1

    for i in range(2, maxim):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def com(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    x,y = map(int, input().split())
    if (x+y) % 3 != 0 or x/2 > y or y > 2*x:
        print(0)
        return

    # (x+y) // 3で何段目かわかる
    # パスカルの三角形で言うところのハジから何番目かがわかればいい

    # k段目の点は -x + 3*k上にある
    # 2*xが一番端にある

    if y < x:
        y,x = x,y
        # パスカルの三角形は左右対称
    
    k = (x+y) // 3
    # k段目の上端は (k, 2k)に存在する
    # 左から何番目かは2*k -yで求まる
    # 解は kC2*k-y

    cominit()
    print(comb(k, 2*k-y))


    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

from math import factorial
import sys

x, y = map(int, input().split())

maxim = 10**6+10
mod = 10**9 + 7

fac = [None] * maxim
finv = [None] * maxim
inv = [None] * maxim

def cominit():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1

    for i in range(2, maxim):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def com(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    if (x + y) % 3 != 0:
        return 0
    else:

        b = (2*y - x) // 3 
        a = b + x -y
        if a < 0 or b < 0:
            print(0)
            sys.exit()
        
        cominit()
        ans = com(a+b, b)
        return ans 
    # answer = (a+b)! / a!b! mod 10^9+7


    
print(main())

# 999999 999999
### BUGGY CODE ###

from collections import Counter
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    lis = tuple(map(int,input().split()))
    ans = Counter(lis)
    for j in range(n):
        su = 0
        for k, v in ans.items():
            if k == lis[j]:
                su += (v - 2) * (v - 1) // 2
            else:
                su += (v - 1) * v // 2
        print(su)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    lis = list(map(int,input().split()))
    d = Counter(lis)
    su = 0
    for e in d:
        su += (d[e] - 1) * d[e] // 2

    for e in lis:
        if d[e] <= 1:
            print(su)
        else:
            k = d[e]
            res = su - k*(k-1)//2 + (k-1)*(k-2)//2
            print(res)

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

from math import ceil

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

d = 1
i = 2
if N == 1:
  d = P
else:
  while i <= ceil(pow(P, 1/N)):
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)

### FIXED CODE ###

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

if N == 1:
  d = P
else:
  d = 1
  i = 2
  while i <= round(pow(P, 1/N)):
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)
### BUGGY CODE ###

n = int(input())

from collections import defaultdict

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

d = defaultdict(int)

for el in a:
    d[el] += 1

count = 0

d = sorted(d.items(), reverse=True)
# wm = d[0][0]

while len(d):
    a, c = d.pop()
    if c == 1:
#         print(f'count {a=}, {c=}, {count=}, {d=}')
        count += 1
    if a == 1:
        break
#     if len(d):
#         m = d[0][0]
#     else:
#         m = a - 1
    if a * 2 <= 10 ** 6:
        d = [elm for elm in d if elm[0] % a]
    else:
        d = [elm for elm in d if elm[1] == 1]
        count += len(d)
        break

print(count)

### FIXED CODE ###

n = int(input())
aa = list(map(int, input().split()))

c = [0]*(10**6+1)

for a in aa:
    c[a] += 1

d = [False]*(10**6+1)

count = 0

for i in range(1, 10**6+1):
    if not c[i]:
        continue
    if d[i]:
        continue
    if c[i] == 1:
        count += 1
    for j in range(i, 10**6+1, i):
        d[j] = True

print(count)
### BUGGY CODE ###

n,m=map(int,input().split())
f=lambda x:int(x)-1
l=[[] for _ in range(n)]
for i in range(m):
  a,b=map(f,input().split())
  l[a].append(b)
  l[b].append(a)
m=0  
vis=[]
for i in range(n):
  queue=[i]
  visit=set()
  visit.add(i)
  cnt=1
  while len(queue)>0:
    now=queue.pop(0)
    for j in l[now]:
      if j not in visit:
        visit.add(j)
        queue.append(j)
        cnt+=1
  m=max(m,cnt)
  vis+=list(visit)
  if len(vis)==n:
    break
print(m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

par=[i for i in range(n)]

def find(x):
  if x==par[x]:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def union(x,y):
  x=find(x)
  y=find(y)
  if x!=y:
    par[x]=y
 
f=lambda x:int(x)-1
for i in range(m):
  x,y=map(f,input().split())
  union(x,y)
  
for j in range(n):
  find(j)
from collections import Counter
c=Counter(par)
cv=c.values()
print(max(cv))
### BUGGY CODE ###

N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

import numpy as np

A_np = np.array(A_list)
C_np = np.array(C_list)

sum_conbi = 0
for B in B_list:
    sum_conbi += np.count_nonzero(A_np < B) * np.count_nonzero(C_np > B)

print(sum_conbi)


### FIXED CODE ###

N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

A_sort = sorted(A_list)
C_sort = sorted(C_list)

# print("A:", A_sort)
# print("C:", C_sort)

def is_ok_lower(list_data, index: int, key: int):
    if (list_data[index] >= key):
        return True
    else:
        return False

def is_ok_upper(list_data, index: int, key: int):
    if (list_data[index] > key):
        return True
    else:
        return False


def binary_search(list_data, key: int, is_ok_func):
    ng = -1  #「index = 0」が条件を満たすこともあるので、初期値は -1
    ok = len(list_data) # 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    # どんな二分探索でもここの書き方を変えずにできる！
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2

        if (is_ok_func(list_data, mid, key)):
            ok = mid
        else:
            ng = mid

    # left は条件を満たさない最大の値、ok は条件を満たす最小の値になっている
    return ok

sum_conbi = 0
for B in B_list:
    a_key = binary_search(A_sort, B, is_ok_lower)
    c_key = binary_search(C_sort, B, is_ok_upper)

    # print(a_key, N-c_key)
    # print(B,">", A_sort[:a_key])
    # print(B,"<", C_sort[c_key:])

    sum_conbi += (a_key) * (N-c_key)

print(sum_conbi)
### BUGGY CODE ###

import math
n = int(input())

ans = 0

for j in range(1,n+1):
    y = math.floor(n/j)
    ans += y*(y+1)*j/2

print(int(ans))


### FIXED CODE ###

import math
n = int(input())

ans = 0

for j in range(1,n+1):
    y = n//j
    ans += y*(y+1)*j/2

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

N, W = map(int, input().split())
weights, values = [], []
for _ in range(N):
    w, v = map(int, input().split())
    weights.append(w)
    values.append(v)

def solve(n, w ,weights, values):
    def rec_solve(cw, cv, max_w, i):
        nonlocal weights, values
        #print(cw, cv, i)
        if i == -1:
            return cv
        
        # take
        if weights[i] + cw <= max_w:
            return max(rec_solve(cw+weights[i], cv + values[i], max_w, i-1),
                        rec_solve(cw, cv, max_w, i-1))

        else:
            # dont take
            return rec_solve(cw, cv, max_w, i-1)

    return rec_solve(0, 0, w, n-1)


print(solve(N, W, weights, values))

### FIXED CODE ###

N, W = map(int, input().split())
weights, values = [], []
for _ in range(N):
    w, v = map(int, input().split())
    weights.append(w)
    values.append(v)

def solve(n, w ,weights, values):
    def rec_solve(cw, cv, max_w, i):
        nonlocal weights, values
        #print(cw, cv, i)
        if i == -1:
            return cv
        
        # take
        if weights[i] + cw <= max_w:
            return max(rec_solve(cw+weights[i], cv + values[i], max_w, i-1),
                        rec_solve(cw, cv, max_w, i-1))

        else:
            # dont take
            return rec_solve(cw, cv, max_w, i-1)

    return rec_solve(0, 0, w, n-1)

def solve_fast(n_items, max_w, weights, values):
    dp =  [[0]*(max_w+1) for _ in range(n_items)]
    dp[0] = [values[0] if i >= weights[0] else 0 for i in range(max_w+1)]

    for r in range(1, n_items):
        cw, cv = weights[r], values[r]
        for c in range(max_w+1):
            if cw > c:
                dp[r][c] = dp[r-1][c]
            else:
                dp[r][c] = max(dp[r-1][c], dp[r-1][c-cw] + cv)

    #for r in dp:
        #print(r)

    return dp[-1][-1]


print(solve_fast(N, W, weights, values))
### BUGGY CODE ###

h,n=map(int,input().split())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

dp=[10**10 for i in range(h+1)]

dp[h]=0

for i in reversed(range(1,h+1)):
    for j in range(n):
        if i-A[j]>=0:
            dp[i-A[j]]=min(dp[i-A[j]],dp[i]+B[j])
        else:
            dp[0]=min(dp[0],dp[i]+B[j])

print(dp[0])

### FIXED CODE ###

h,n=map(int,input().split())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

dp=[10**10 for i in range(h+1)]

dp[h]=0

for i in reversed(range(1,h+1)):
    for j in range(n):
        if i-A[j]>=0:
            dp[i-A[j]]=min(dp[i-A[j]],dp[i]+B[j])
        else:
            dp[0]=min(dp[0],dp[i]+B[j])

print(dp[0])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
flg=1
while flg>0:
  flg=0
  for i in range(n):
    j = a.index(max(a))
    if a[j] % a[i] > 0:
      a[j] = a[j] % a[i]
      flg=1
print(min(a))

### FIXED CODE ###

import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n = input()
a = list(map(int,input().split()))
print(gcd_list(a))