Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())) , key=abs , reverse=1)
import bisect as bi
# print(A)
# import numpy as np
# G=np.prod(A[:k])
def seki(A,mod=10**9+7):
    now=1
    for i in A:
        i=abs(i)
        if i>0 : now*=i
        # if i<0 : now*=i
        if i==0 :return 0
        if now>0 : now%=mod
    return now

CH=A[:k] 
NO=A[k:]
# G=seki(A[:k])

mod=10**9+7
# if G>=0 : print(G%mod) ; exit()
if sum([A[i]>0 for i in range(n)])==0 and k%2==1:
  print((-seki(A[n-k:]))%mod) ;exit()
if n==k and len(A[bi.bisect_left(A,-1):])%2==1 :
    print((-seki(A))%mod) ;exit()
if sum([i<0 for i in A[:k]])%2==0 :
    print(seki(A[:k])%mod) ; exit()
if 0 in CH:
    print(0);exit()
  
# done=0 ; done2=0
# # ch=-73267983297 ; ch2=-9263498381621
# 
# for i in range(k-1,-1,-1):
#     if A[i]<0 and done==0:
#         for j in range(i+1,n):
#             if A[j]>=0: 
#                 # ch=G*A[j]//A[i]
#                 x1=A[j] ; y1=A[i]
#                 done=1
#                 break
#     if A[i]>0 and done2==0:
#         for j in range(i+1,n):
#             if A[j]<=0: 
#                 # ch2=G*A[j]//A[i]
#                 x2=A[j] ; y2=A[i]
#                 done2=1
#                 break
# #     if done==1 and done2==1 : break
# 
# G=seki(A[:k])
# G=-G
# if done and done2 :
#     if x1 * y2 > x2 * y1 :
#         print((G*x1//y1)%mod)
#     else:
#         print((G*x2//y2)%mod)
# elif done==1:
#     print((G*x1//y1)%mod)
# elif done2==1:
#     print((G*x2//y2)%mod)
        

done=0 ; done2=0
muri,muri2=0,0

# x1,x2,y1,y2=0,0,0,0
if sum([i>=0 for i in NO])==0 : #NO全部-
    muri=1
if sum([i>=0 for i in CH])==0 : #CH全部-
    muri2=1
if sum([i<0 for i in NO])==0: #-を入れられない
    muri2=1
    
if muri==0:
    y1= sorted([i for i in CH if i<0])[-1]
    x1= sorted([i for i in NO if i>=0])[-1]
    done=1
if muri2==0:
    y2= sorted([i for i in CH if i>0])[0]
    x2= sorted([i for i in NO if i<0])[0]
    done2=1

if done and done2:
    if x1 * y2 > x2 * y1 :
        print((-seki(CH)*x1//y1)%mod)
    else:
        print((-seki(CH)*x2//y2)%mod)
elif muri:
    print((-seki(CH)*x2//y2)%mod)
else:
    print((-seki(CH)*x1//y1)%mod)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
ans=1

if K%2==1 and A[-1]<0:
    for i in range(K):
        ans=ans*A[N-(i+1)]%mod
    print(ans)
    exit()

l=0
r=N-1
if K%2==1:
    ans=ans*A[r]
    r-=1

for _ in range(K//2):
    ml=A[l]*A[l+1]
    mr=A[r]*A[r-1]
    if ml>mr:
        ans=ans*ml%mod
        l+=2
    else:
        ans=ans*mr%mod
        r-=2

print(ans)
task=list(map(int,intput().split()))
task.sort()
cost=0
for i in range(1,3):
    cost+=task[i]-task[i-1]

print(cost)


### FIXED CODE ###

task=list(map(int,input().split()))
print(sorted(task)[2]-sorted(task)[0])
A, B, C, D, E, F = map(int, input())

waters = set()
for i in range(F + 1):
    for j in range(F + 1):
        water = 100 * A * i + 100 * B * j
        if water <= F:
            waters.add(water)
waters.remove(0)

sugars = set()
for i in range(F + 1):
    for j in range(F + 1):
        sugar = C * i + D * j
        if sugar <= F:
            sugars.add(sugar)

max_percentage = 0
max_water = 0
max_sugar = 0
limit_percentage = (100 * E) / (100 + E)

for water in waters:
    for sugar in sugars:
        percentage = (100 * sugar) / (water + sugar)
        if max_percentage < percentage <= limit_percentage and water + sugar <= F:
            max_percentage = percentage
            max_water = water
            max_sugar = sugar

print('{} {}'.format(max_water + max_sugar, max_sugar))

### FIXED CODE ###

def concentration(water, suger):
  return 100 * suger / (water + suger)

WATER_A, WATER_B, SUGER_C, SUGER_D, MELT_PER_100, LIMIT = map(int, input().split())

WATER_A *= 100
WATER_B *= 100
# 砂糖の溶解率の上限
MELT_PERCENT_LIMIT = concentration(100, MELT_PER_100)

wa = wb = sc = sd = 0

water_set = set()
while wa * WATER_A <= LIMIT:
  while wb * WATER_B <= LIMIT:
    water = wa * WATER_A + wb * WATER_B
    if water <= LIMIT:
      water_set.add(water)
    wb += 1
  wb = 0
  wa += 1

suger_set = set()
while sc * SUGER_C <= LIMIT:
  while sd * SUGER_D <= LIMIT:
    suger = sc * SUGER_C + sd * SUGER_D
    if suger <= LIMIT:
      suger_set.add(suger)
    sd += 1
  sd = 0
  sc += 1

ans_suger_water = 0
ans_suger = 0
# 最大溶解率を保持するための変数
max_concentration = 0

for water in water_set:
  for suger in suger_set:
    # 砂糖水の量が0より大きく制限量以下以外の場合は次のループへ
    if not (0 < water + suger <= LIMIT):
      continue
    # 砂糖濃度計算
    suger_precent = concentration(water, suger)
    # 砂糖濃度が最高を更新かつ限界濃度を超えていなければ答えを更新
    if max_concentration <= suger_precent <= MELT_PERCENT_LIMIT:
      max_concentration = suger_precent
      ans_suger_water = water + suger
      ans_suger = suger

print(ans_suger_water, ans_suger)
from copy import deepcopy

def getval():
    n = int(input())
    return n

def main(n):
    mod = 10**9 + 7
    #A:0 C:1 G:2 T:3
    dp = [[[1 for i in range(4)] for i in range(4)] for i in range(4)]
    dp[0][2][1] = 0
    dp[0][1][2] = 0
    dp[2][0][1] = 0

    def pow4(arr):
        ans = 0
        for i in range(4):
            ans += arr[i]*(4**(3-i))
        return ans 

    p = []
    for i in range(4):
        p.append(pow4([0,2,1,i]))
        p.append(pow4([0,1,2,i]))
        p.append(pow4([2,0,1,i]))
        p.append(pow4([i,0,2,1]))
        p.append(pow4([i,0,1,2]))
        p.append(pow4([i,2,0,1]))
        p.append(pow4([0,i,2,1]))
        p.append(pow4([0,2,i,1]))

    it1 = iter(p)
    it2 = iter(p)
    co = 0
    di = dict(zip(it1,it2))
    for i in range(n-3):
        temp = [[[0 for i in range(4)] for i in range(4)] for i in range(4)]
        for a in range(4):
            for b in range(4):
                for c in range(4):
                    for d in range(4):
                        if pow4([a,b,c,d]) in di:
                            temp[b][c][d] += 0
                        else:
                            temp[b][c][d] += dp[a][b][c]
                            temp[b][c][d] %= mod
        dp = temp

    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans += temp[i][j][k]
    ans %= mod
    print(ans)

if __name__=="__main__":
    n = getval()
    main(n)

### FIXED CODE ###

from copy import deepcopy

def getval():
    n = int(input())
    return n

def main(n):
    mod = 10**9 + 7
    #A:0 C:1 G:2 T:3
    dp = [[[1 for i in range(4)] for i in range(4)] for i in range(4)]
    dp[0][2][1] = 0
    dp[0][1][2] = 0
    dp[2][0][1] = 0

    def pow4(arr):
        ans = 0
        for i in range(4):
            ans += arr[i]*(4**(3-i))
        return ans 

    p = []
    for i in range(4):
        p.append(pow4([0,2,1,i]))
        p.append(pow4([0,1,2,i]))
        p.append(pow4([2,0,1,i]))
        p.append(pow4([i,0,2,1]))
        p.append(pow4([i,0,1,2]))
        p.append(pow4([i,2,0,1]))
        p.append(pow4([0,i,2,1]))
        p.append(pow4([0,2,i,1]))

    it1 = iter(p)
    it2 = iter(p)
    co = 0
    di = dict(zip(it1,it2))
    for i in range(n-3):
        temp = [[[0 for i in range(4)] for i in range(4)] for i in range(4)]
        for a in range(4):
            for b in range(4):
                for c in range(4):
                    for d in range(4):
                        if pow4([a,b,c,d]) in di:
                            temp[b][c][d] += 0
                        else:
                            temp[b][c][d] += dp[a][b][c]
                            temp[b][c][d] %= mod
        dp = temp

    ans = 0
    if n>=4:
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    ans += temp[i][j][k]
    elif n==3:
        ans = 61
    ans %= mod
    print(ans)

if __name__=="__main__":
    n = getval()
    main(n)
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(n):
    b1.append(b1[-1]+b[i])
ans=0
j=m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print ans

### FIXED CODE ###

n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(m):
    b1.append(b1[-1]+b[i])
ans=0
j=m
for i in range(n+1):
    if a1[i]>k:
        break
    while b1[j]>k-a1[i]:
        j-=1
    ans=max(ans,i+j)
print ans
MOD = 10**9 + 7

def ex_euclid(a,b,c,d):
    if (b == 1) : return d
    x = a // b
    y = a % b
    return ex_euclid(b,y,d,(c[0]-x*d[0],c[1]-x*d[1]))
    
 
def mod_inv(a,p):
    x = ex_euclid(p,a,(1,0),(0,1))
    return x[1] % p

n,a,b,c,d = map(int,input().split())

gp = b-a+1

dp = [[-1 for j in range(n+1)] for i in range(gp)]

tb1=[0,1]
tb2=[1] #便宜上0の逆元は0にする
for i in range(2,n+1):
    tb1.append((tb1[i-1]*i) % MOD)
for i in range(1,n+1):
    tb2.append(mod_inv(tb1[i],MOD))
    

for i in range(gp):dp[i][0] = 1


def dfs(sum,k):
    summ = sum
    if(k < 0):
        if (sum != 0):return 0
        else : return 1
    if dp[k][sum] != -1: return dp[k][sum]
    kk = k+a
    temp = dfs(sum,k-1)
    temp1 = 1
    for i in range(c-1):
        if (sum < 0):break
        temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD 
        sum -= kk
    for i in range(c,d+1):
        if(sum-kk < 0) : break
        temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD
        sum -= kk
        temp = (temp + temp1*dfs(sum,k-1)*tb2[i]) % MOD

    dp[k][summ] = temp
    return temp
    

        
ans = dfs(n,gp-1)



print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

MOD = 10**9 + 7

def ex_euclid(a,b,c,d):
    if (b == 1) : return d
    x = a // b
    y = a % b
    return ex_euclid(b,y,d,(c[0]-x*d[0],c[1]-x*d[1]))
    
 
def mod_inv(a,p):
    x = ex_euclid(p,a,(1,0),(0,1))
    return x[1] % p

n,a,b,c,d = map(int,input().split())

gp = b-a+1

dp = [[-1 for j in range(n+1)] for i in range(gp)]

tb1=[0,1]
tb2=[1] #便宜上0の逆元は0にする
for i in range(2,n+1):
    tb1.append((tb1[i-1]*i) % MOD)
for i in range(1,n+1):
    tb2.append(mod_inv(tb1[i],MOD))
    

for i in range(gp):dp[i][0] = 1


def dfs(sum,k):
    summ = sum
    if(k < 0):
        if (sum != 0):return 0
        else : return 1
    if dp[k][sum] != -1: return dp[k][sum]
    kk = k+a
    temp = dfs(sum,k-1)
    temp1 = 1
    for i in range(c-1):
        if (sum < 0):break
        temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD 
        sum -= kk
    for i in range(c,d+1):
        if(sum-kk < 0) : break
        temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD
        sum -= kk
        temp = (temp + temp1*dfs(sum,k-1)*tb2[i]) % MOD

    dp[k][summ] = temp
    return temp
    

        
ans = dfs(n,gp-1)



print(ans)
lengthNum, countNum, sumNum = map(int, input().split())

aryAns = []
tmp = lengthNum - countNum
tNum = 2 if sumNum == 1 else sumNum-1
aryAns = [sumNum]*countNum + [sumNum-1]*tmp

print(" ".join([str(x) for x in aryAns]))


### FIXED CODE ###

def countChange(inputNum, divNum):
    tmp = inputNum // divNum
    if inputNum % divNum != 0:
        tmp += 1

    return tmp

height = int(input())
width = int(input())
goal = int(input())

if height > width:
    divNum = height
else:
    divNum = width

ans = countChange(goal, divNum)
print(ans)
#20　AtCoder Beginner Contest 077 C - Snuke Festival
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
    if i <= a[n-1]: lena=len(a[:bisect.bisect_left(a, i)])
    else: lena=n
    if i+1<= c[n-1]: lenc=len(a[bisect.bisect_left(c, i+1):])
    ans += lena*lenc
print(ans)

### FIXED CODE ###

#20　AtCoder Beginner Contest 077 C - Snuke Festival
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
    ans+= (bisect.bisect_right(a, i-1))*(n-bisect.bisect_left(c, i+1))
print(ans)
n=input()
for i in range(n):
    t,x,y=map(int,input().split())
    if x+y<=n and t%2==(x+y)%2:
        count+=1
print("YES" if count==n else "NO")

### FIXED CODE ###

import sys
N=int(input())
for i in range(N):
  t,x,y=map(int,input().split())
  if (x+y)%2==t%2 and x+y<=t:
    pass
  else:
    print('No')
    sys.exit()
print('Yes')
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
nsum=0
for i in range(n):
    b[a[i]]+=1
for k in range(n):
    nsum+=max(b[k]*(b[k]-1)//2,0)


for j in range(n):
    print((nsum+1-b[a[j]]))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
nsum=0
for i in range(n):
    b[a[i]]+=1
for k in range(n+1):
    nsum+=max(b[k]*(b[k]-1)//2,0)

for j in range(n):
    print((nsum+1-b[a[j]]))
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=1
cnt=0
while d<=x:
  cnt+=1
  d+=l[i-1]
  i+=1
  
print(cnt)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))+[0]
#i=1
d=0
cnt=0
for i in range(n+1):
  if d<=x:
    cnt+=1
    d+=l[i]

  
print(cnt)
#!/usr/bin/env python3
import math
# n進数の各位の和
def base_10_n(x,n):
    tmpx = x
    a = int(math.log(x,n))
    ans = 0
    for i in range(a,-1,-1):
        ans += tmpx // n**i
        tmpx %= n**i
    ans += tmpx
    return ans

def main():
    N = int(input())
    ans = base_10_n(N,6)
    for j in range(1, (N//9)+1):
        c = base_10_n(N-9*j,6)
        d = base_10_n(9*j,9)
        ans = min(ans, c+d)
    print(ans)
    # print(base_10_n(-1,6))
    # print([i for i in range(1,(26//9)+1)])

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import math
# n進数の各位の和


def base_10_n(x, n):
    if x == 0:
        return 0
    tmpx = x
    a = int(math.log(x, n))
    ans = 0
    for i in range(a, -1, -1):
        ans += tmpx // n**i
        tmpx %= n**i
    ans += tmpx
    return ans


def s(n, r):
    if n == 0:
        return 0
    return n % r + s(n // r, r)


def main():
    N = int(input())
    ans = 10**12
    for j in range(N+1):
        # c = base_10_n(N-j, 6)
        # d = base_10_n(j, 9)
        c = s(j,6)
        d = s(N-j,9)
        ans = min(ans, c+d)
    print(ans)


if __name__ == "__main__":
    main()
n,m=map(int,input().split())
A=[input() for i in range(n)]
B=[input() for i in range(m)]

for i in range(n):
  for j in range(n):
    k=j+m
    if k <= n:
      if A[i][j:k]== B[0]:
        o=1
        for l in range(i+1,i+m):
          if A[l][j:k]!=B[o]:
            break
          else:
            o+=1
        if o==m:
          print('Yes')
          exit()
print('No')



### FIXED CODE ###

n,m=map(int,input().split())
A=[input() for i in range(n)]
B=[input() for i in range(m)]

for i in range(n):
  for j in range(n):
    k=j+m
    if k <= n:
      if A[i][j:k]== B[0]:
        o=1
        for l in range(i+1,i+m):
          if l<n:
            if A[l][j:k]!=B[o]:
              break
            else:
              o+=1
        if o==m:
          print('Yes')
          exit()
print('No')
x,y = list(map(decimal.Decimal,input().split()))
y*=100
print(math.floor((x*y)/100))


### FIXED CODE ###

import math
import decimal
x,y = list(map(decimal.Decimal,input().split()))
print(math.floor(x*y))
from collections import deque

class Process:
  def __init__(self, name, time):
    self.name = name
    self.time = time

  def getName(self):
    return self.name

  def getTime(self):
    return self.time

  def setTime(self, time):
    self.time = time

queue = deque()
n, q = map(int, raw_input().split())
for _ in xrange(n):
  name, time = raw_input().split()
  queue.append(Process(name, int(time)))
t = 0
while nameq:
  p = queue.popleft()
  if p.getTime() > q:
    p.setTime(p.getTime()-q)
    queue.append(p)
    t += q
  else:
    t += time
    print "%s %d" % (p.getName(), p.getTime())

### FIXED CODE ###

from collections import deque

nameq = deque()
timeq = deque()
n, q = map(int, raw_input().split())
for _ in xrange(n):
  name, time = raw_input().split()
  nameq.append(name)
  timeq.append(int(time))

t = 0
while nameq:
  name = nameq.popleft()
  time = timeq.popleft()
  if time > q:
    time -= q
    nameq.append(name)
    timeq.append(time)
    t += q
  else:
    t += time
    print "%s %d" % (name, t)
import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0
 
for i in range(len(l)-2):
    for j in range(i+1,len(l)-1):
        s = bisect.bisect_left(l[i]+l[j])
        a += n-s-1 


print(a)

### FIXED CODE ###

import bisect
n = int(input())
 
l = list(map(int, input().split()))
l.sort()
a = 0
#print(l)
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l,l[i]+l[j])-j-1
        a+=s


print(a)
b=raw_input()
#b=str(b_in)
if b=="A":
  print("T")
elif b=="G":
  print("C")
elif b=="T":
  print("A")
elif b=="C":
  print("G")

### FIXED CODE ###

b=input()

if b == 'A':
    ans='T'
elif b == 'T':
    ans='A'
elif b == 'G':
    ans='C'
elif b == 'C':
    ans='G'

print(ans)
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
print(N-max(s_dict.values()))


### FIXED CODE ###

import math
N = int(input())
s_dict = {}
cood_list=[]
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(len(cood_list)):
        p = a - cood_list[j][0]
        q = b - cood_list[j][1]
        if 0 > p:
            p = -p
            q = -q
        elif p == 0:
            q = abs(q)
        s = str(p)+","+str(q)
        if s not in s_dict:
            s_dict[s] = 1
        else:
            s_dict[s] += 1
    cood = [a,b]
    cood_list.append(cood)
if N != 1:
    print(N-max(s_dict.values()))
else:
    print(1)
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)

### FIXED CODE ###

import sys
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
    sys.exit()
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)
import numpy as np

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

def calc(a):
    value = a[0]
    sign = value >= 0
    result = 0
    for i in a[1:]:
        value += i
        diff = 0
        if sign and value >= 0:
            diff = value + 1
        elif not sign and value < 0:
            diff = value - 1
        result += abs(diff)
        sign = not sign
        value -= diff
        if value == 0:
            diff += sign
            value += diff
            result += diff
    return result

r1 = calc(a[:])
diff = -a[0] - a[0] // abs(a[0])
a[0] += diff
r2 = calc(a[:]) + abs(diff)
print(min(r1, r2))


### FIXED CODE ###

import numpy as np

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

def calc(a):
    value = a[0]
    sign = value >= 0
    result = 0
    for i in a[1:]:
        value += i
        diff = 0
        if sign and value >= 0:
            diff = value + 1
        elif not sign and value < 0:
            diff = value - 1
        result += abs(diff)
        sign = not sign
        value -= diff
        if value == 0:
            diff += sign
            value += diff
            result += diff
    return result

if a[0] == 0:
    a[0] = 1
    r1 = calc(a[:])
    a[0] = -1
    r2 = calc(a[:])
    print(min(r1, r2) + 1)
else:
    r1 = calc(a[:])
    diff = -a[0] - a[0] // abs(a[0])
    a[0] += diff
    r2 = calc(a[:]) + abs(diff)
    print(min(r1, r2))
import math

N = int(input())
A = [int(i) for i in input().split()]
ans = A[N - 1]
for i in range(N - 1):
    ans = math.gcd(ans, A[i])
print(ans)


### FIXED CODE ###

def gcd(x, y):
    if y > x:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x


N = int(input())
A = [int(i) for i in input().split()]
ans = A[N - 1]
for i in range(N - 1):
    ans = gcd(ans, A[i])
print(ans)
from math import gcd
a,b,c,d=map(int,input().split())
print(b-a-(b-a)//c-(b-a)//d+(b-a)//(c*d//gcd(c,d)))


### FIXED CODE ###

from fractions import gcd
a,b,c,d=map(int,input().split())
e=c*d//gcd(c,d)
x=b//c+b//d-b//e
y=(a-1)//c+(a-1)//d-(a-1)//e
print(b-a+1-(x-y))
S=input()
mod=10**9 + 7
dp=[[0,0,0] for i in range(len(S))]
dp[0][0]=2
dp[0][2]=1

for i in range(1,len(S)):
   if S[i]=="1":
      dp[i][0]+=dp[i-1][0]* 2 % mod  
      dp[i][2]+=dp[i-1][0]* 1 % mod 
   else:
      dp[i][0]+=dp[i-1][0]* 1 % mod 
   dp[i][1]+=(dp[i-1][1]+dp[i-1][2]) * 2 % mod
   dp[i][2]+=(dp[i-1][1]+dp[i-1][2]) * 1 % mod                 
   dp[i][0]%=mod             
   dp[i][1]%=mod
   dp[i][2]%=mod
value=(dp[i][0]+dp[i][1]+dp[i][2])%mod
print(value)
            
                 
   

### FIXED CODE ###

S=input()
mod=10**9 + 7
dp=[[0,0,0] for i in range(len(S))]
dp[0][0]=2
dp[0][2]=1

for i in range(1,len(S)):
   if S[i]=="1":
      dp[i][0]+=dp[i-1][0]* 2 % mod  
      dp[i][2]+=dp[i-1][0]* 1 % mod 
   else:
      dp[i][0]+=dp[i-1][0]* 1 % mod 
   dp[i][1]+=(dp[i-1][1]+dp[i-1][2]) * 2 % mod
   dp[i][2]+=(dp[i-1][1]+dp[i-1][2]) * 1 % mod                 
   dp[i][0]%=mod             
   dp[i][1]%=mod
   dp[i][2]%=mod
value=(dp[-1][0]+dp[-1][1]+dp[-1][2])%mod
print(value)
s = input().split()[1][0]

print(f'A{s}C')

### FIXED CODE ###

s = input().split()[1]

print('A' + s[0] + 'C')
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if max(x) < min(y):
    for i in range(max(x),min(y)+1):
        if max(x) < i <= min(y) and X < i <= Y:
             print("No War")
             exit(1)
print("War")
             


### FIXED CODE ###

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for i in range(X, Y+1):
  if X < i <= Y and max(x) < i <= min(y):
    print("No War")
    exit()
print("War")
N = int(input())
A = list(map(int, input().split()))
ans = 1
for number in A:
  ans *= number
if ans <= 1000000000000000000:
  print(ans)
else:
  print('-1')

### FIXED CODE ###

A, B = list(map(int, input().split()))
print(A*B)
lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(len(lock_num)-1):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
if tag == 0:
  print("Good")
else tag ==1:
  print("Bad")

### FIXED CODE ###

lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
    break
if tag == 0:
  print("Good")
else:
  print("Bad")
sum = 0
while true:
   x = raw.input()
   sum = sum + 1
   if x == 0:
      break;
for i in range(0,sum):
   print "Case sum: x"

### FIXED CODE ###

sum = 0
while 1:
   x = raw_input()
   sum = sum + 1
   if x == '0':
      break
   print 'Case %s: %s' %(sum, x)
print(R*3.141592*2)

### FIXED CODE ###

R=int(input())
i=R*6.283184
print(i)
N, M = [int(i) for i in input().split()]
s = [0] * M
c = [0] * M
for i in range(M):
  s[i], c[i] = map(int, input().split())

ans = 1000
for i in range(1000):
  S = str(i)
  if len(S) != N:
    continue
  
  is_ok = True
  for j in range(M):
    if S[s[j]] != c[j]:
      is_ok = False
      
  if is_ok:
    ans = min(ans, i)

if ans == 1000:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

N, M = [int(i) for i in input().split()]
s = [0] * M
c = [0] * M
for i in range(M):
  s[i], c[i] = map(int, input().split())

ans = 1000
for i in range(1000):
  S = str(i)
  if len(S) != N:
    continue
  
  is_ok = True
  for j in range(M):
    if S[s[j]-1] != str(c[j]):
      is_ok = False
      
  if is_ok:
    ans = min(ans, i)

if ans == 1000:
  print(-1)
else:
  print(ans)