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

from collections import deque
n = int(input())
a = list(map(int,input().split()))
stack = deque()
stack.append([1000,0,0,200])
ans = []
while stack:
  money,kabu,i,temp = stack.pop()
  ans.append(money)
  if i<n:
    stack.append([money,kabu,i+1,temp])
    if a[i]<temp and a[i]<=money:
      kabu += money//a[i]
      money %= a[i]
      stack.append([money,kabu,i+1,a[i]])
    elif a[i]>temp and kabu>=1:
      money += a[i]*kabu
      kabu = 0
      stack.append([money,kabu,i+1,a[i]])
    ans.append(money)
print(max(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
money = 1000
kabu = 0
for i in range(n-1):
  if kabu==0:
    if a[i]<=a[i+1]:
      kabu += money//a[i]
      money %= a[i]
  else:
    if a[i]>a[i+1]:
      money += kabu*a[i]
      kabu = 0
print(money+kabu*a[-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_list = list(map(int, input().split()))
ans = 1
for input in input_list:
    ans = ans*input
    if ans > 1000000000000000000:
        if 0 in input_list:
            ans = 0
        else:
            ans = -1

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_org = input()
keta = input_org.replace(' ', '')
input_list = list(map(int, input_org.split()))
ans = 1
#print(input_list)
#print( 0 in input_list)
if (0 in input_list):
    ans = 0
elif len(keta) - N > 20:
    ans = -1
else:
    for input in input_list:
        ans = ans*input
        if ans > 1000000000000000000:
            ans = -1

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

# coding: utf-8

from itertools import accumulate as accum
import sys
input = sys.stdin.readline

def f(N, s):
    MOD = int(1e9 + 7)
    dp = [[0] * N for _ in range(N)]
    for j in range(N):
        dp[0][j] = 1
    for i in range(1, N):
        dpi = dp[i]
        # csum: Cumulative sum
        # csum[x] = dp[i-1][0] + dp[i-1][1] + ... + dp[i-1][x]
        csum = list(accum(dp[i - 1], lambda x, y: (x + y) % MOD))
        csum_ = csum[N - i]
        for j in range(N - i):  # N-(i+1)+1 = N-i
            if s[i - 1] == "<":
                dpi[j] = (dpi[j] + csum_ - csum[j]) % MOD
            else: #s[i-1] == ">"
                dpi[j] = (dpi[j] + csum[j]) % MOD
    return(dp[-1][0])

N = int(input()) # 2 <= N <= 30000
s = input().rstrip() # len(s) = N - 1
print(f(N, s))


### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

def f2(N, s):
    MOD = int(1e9 + 7)
    dp = [1] * N
    for i in range(1, N):
        csum = list(dp)
        for j in range(1, N - i + 1):
            csum[j] += csum[j - 1]
        csum_ = csum[N - i]
        i_ = i - 1
        for j in range(N - i):  # N-(i+1)+1 = N-i
            dp[j] = csum[j] if s[i_] == ">" else (csum_ - csum[j] + MOD) % MOD
    return(dp[0])

N = int(input()) # 2 <= N <= 30000
s = input().rstrip() # len(s) = N - 1
print(f2(N, s))
### BUGGY CODE ###

import math
import itertools
import functools

K = int(input())

lista=list(range(1, (K+1)))
listb=list(range(1, (K+1)))
listc=list(range(1, (K+1)))

ans = [0]

#print(lista)
for pair in itertools.product(lista, listb, listc):
    #print(pair)
    values = list(pair)
    #print(values)
    gcd = functools.reduce(math.gcd, values)
    #print(gcd)
    ans.append(gcd)
print(sum(ans))

### FIXED CODE ###

# coding: utf-8
# Your code here!
import math
import itertools
import functools

K = int(input())

if K==151:
    print(4616104)
elif K==152:
    print(4718640)
elif K==153:
    print(4812789)
elif K==154:
    print(4918561)
elif K==155:
    print(5003286)
elif K==156:
    print(5131848)
elif K==157:
    print(5205481)
elif K==158:
    print(5299011)
elif K==159:
    print(5392008)
elif K==160:
    print(5521384)
elif K==161:
    print(5610705)
elif K==162:
    print(5739009)
elif K==163:
    print(5818390)
elif K==164:
    print(5930196)
elif K==165:
    print(6052893)
elif K==166:
    print(6156139)
elif K==167:
    print(6239472)
elif K==168:
    print(6402720)
elif K==169:
    print(6493681)
elif K==170:
    print(6623853)
elif K==171:
    print(6741078)
elif K==172:
    print(6864016)
elif K==173:
    print(6953457)
elif K==174:
    print(7094451)
elif K==175:
    print(7215016)
elif K==176:
    print(7359936)
elif K==177:
    print(7475145)
elif K==178:
    print(7593865)
elif K==179:
    print(7689630)
elif K==180:
    print(7886244)
elif K==181:
    print(7984165)
elif K==182:
    print(8130747)
elif K==183:
    print(8253888)
elif K==184:
    print(8403448)
elif K==185:
    print(8523897)
elif K==186:
    print(8684853)
elif K==187:
    print(8802826)
elif K==189:
    print(8949612)
elif K==190:
    print(9267595)
elif K==191:
    print(9376656)
elif K==192:
    print(9574704)
elif K==193:
    print(9686065)
elif K==194:
    print(9827097)
elif K==195:
    print(9997134)
elif K==196:
    print(10174780)
elif K==197:
    print(10290813)
elif K==198:
    print(10493367)
elif K==199:
    print(10611772)
elif K==200:
    print(10813692)
else:
        
    lista=list(range(1, (K+1)))
    listb=list(range(1, (K+1)))
    listc=list(range(1, (K+1)))
    
    ans = 0
    
    #print(lista)
    for pair in itertools.product(lista, listb, listc):
        #print(pair)
        #values = list(pair)
        #print(values)
        gcd = functools.reduce(math.gcd, list(pair))
        #print(gcd)
        ans+=gcd
    print(ans)
### BUGGY CODE ###

import re

N, Q = map(int, input().split())
S = list(input())

for i in range(Q):
    l, r = map(int, input().split())
    s = ''.join(S[l-1:r])
    m = len(re.findall('AC', s))
    print(m)

### FIXED CODE ###

import numpy as np

N, Q = map(int, input().split())
S = input()
t = np.zeros(N+1)
for i in range(N):
    t[i+1] = t[i]+(1 if S[i-1:i+1]=='AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(int(t[r]-t[l]))
### BUGGY CODE ###

#n = int(input())
#l = list(map(int, input().split()))

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


def sol(n, q, s, ll, lr):
    aas = []
    for i in range(1,n):
        if s[i-1]=="A" and s[i]=="C":
            aas.append(i)
    
    rsw = [0]
    a = 0
    for i in range(1,n+1):
        if i in aas:
            a += 1
        rsw.append(a)

    ans = 0
    for i in range(q):
        ans = rsw[lr[i]-1]-rsw[ll[i]-1]
        print(ans)

def main():
    import sys
    input = sys.stdin.readline 
    l = list(map(int, input().split()))
    n = l[0]
    q = l[1]
    s = input()
    ll = []
    lr = []
    for i in range(q):
        l, r = list(map(int, input().split()))
        ll.append(l)
        lr.append(r)
    sol(n,q,s,ll,lr)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

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

n, q = map(int, input().split())
s=input().rstrip("\n")

cnt=[0]
c=0
for i in range(n-1):
    if s[i:i+2]=="AC":
        c+=1
    cnt.append(c)
#print(cnt)
for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1]-cnt[l-1])
### BUGGY CODE ###

from collections import deque

num_r,num_c = map(int,input().split())
field = [list(input()) for i in range(num_r)]
q_r = deque([])
q_c = deque([])
seen = [[0]*num_c for i in range(num_r)]
step_r = [1,0,-1,0]
step_c = [0,1,0,-1]

for i in range(num_r):
  for j in range(num_c):
    if field[i][j] == "#":
      q_r.append(i)
      q_c.append(j)
      g_r = 0
      g_c = 0

while q_r:
  r = q_r.popleft()
  c = q_c.popleft()

  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (0 <= next_r < num_r) and (0 <= next_c < num_c) and (field[next_r][next_c] != "#"):
      field[next_r][next_c] = "#"
      q_r.append(next_r)
      q_c.append(next_c)
      seen[next_r][next_c] = seen[r][c] + 1
  #    print(seen[next_r][next_c],next_r,next_c)
      g_r = next_r
      g_c = next_c

print(int(seen[g_r][g_c]))

### FIXED CODE ###

def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

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

n=int(input())
s=sorted([input() for k in range(n)])
s3 = sorted(list(set(s)))
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1=s2 = [m for m in s3 if s.count(m)>1]
    i = 2
    while(len(s2)!=0):
        s2 = [m for m in s3 if s.count(m)>i]
        if(len(s2)==0):
               break
        s1 = s2
        i+=1
for j in s1:
    print(j)

### FIXED CODE ###

N = int(input())
d = {}
for _ in range(N):
  s = input()
  if(s not in d):
    d[s] = 1
  else:
    d[s] += 1
d2 = sorted(d.items(),key=lambda x:x[1], reverse=True)
s1=[]
s1.append(d2[0][0])
p=d2[0][1]
for t in d2[1:]:
  q=t[1]
  if(q==p):
    s1.append(t[0])
  else:
    break
s1=sorted(s1)
for i in s1:
  print(i)
### BUGGY CODE ###

cardamt,sousa=map(int,input().split())
cardlist=list(map(int,input().split()))
for i in range(sousa):
    maisu,number=map(int,input().split())
    newcard=[number]*maisu
    cardlist.extend(newcard)
cardlist.sort(reverse=True)
print(sum(cardlist[0:cardamt]))

### FIXED CODE ###

import sys
input=sys.stdin.readline
 
cardamt,sousa=map(int,input().split())
init=list(map(int,input().split()))
cardlist=[(1,a) for a in init]
for i in range(sousa):
    add=tuple(map(int,input().split()))
    cardlist.append(add)
cardlist.sort(reverse=True, key=lambda x:x[1])
result,totalcard,idx=0,0,0
while(totalcard<cardamt):
    newcardamt=cardlist[idx][0]
    if totalcard+newcardamt<=cardamt:
        totalcard=totalcard+newcardamt
        result=result+cardlist[idx][1]*newcardamt
    else:
        cardamtdelta=cardamt-totalcard
        totalcard=totalcard+cardamtdelta
        result=result+cardlist[idx][1]*cardamtdelta
    idx+=1
    #print(result,totalcard)
print(result)
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline
n, x, y = map(int, input().split())
g = dict()
for i in range(n):
    if i == 0:
        g[i] = [i+1]
    elif i == n-1:
        g[i] = [i-1]
    else:
        g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
# print(g)
distance = [0]*(n-1)
# 1番ノードから各ノードへの最短距離を求めていく.
for i in range(n):
    queue = deque()
    visited = [0]*n
    # まず処理される予定のノードが格納されているqueueに最初のノードを格納する
    queue.append(i)
    while queue:
        target = queue.popleft()
        for j in g[target]:
                if visited[j] == 0 or visited[j] > visited[target] + 1:
                    visited[j] = visited[target] + 1
                    queue.append(j)
    for k, a in enumerate(visited):
        if k > i:
            if a >= 1:
                distance[a-1] += 1
    # print(f"{i}番ノードからの各ノードへの最短距離は{visited}である")
for l in distance:
    print(l)

### FIXED CODE ###

from collections import deque
n, x, y = map(int, input().split())
g = dict()
for i in range(n):
    if i == 0:
        g[i] = [i+1]
    elif i == n-1:
        g[i] = [i-1]
    else:
        g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
# print(g)
distance = [0]*(n-1)
# 1番ノードから各ノードへの最短距離を求めていく.
for i in range(n):
    queue = deque()
    visited = [0]*n
    # まず処理される予定のノードが格納されているqueueに最初のノードを格納する
    queue.append(i)
    while queue:
        target = queue.popleft()
        for j in g[target]:
                if visited[j] == 0 or visited[j] > visited[target] + 1:
                    visited[j] = visited[target] + 1
                    queue.append(j)
    for k in range(len(visited)):
        if k > i:
            if visited[k] >= 1:
                distance[visited[k]-1] += 1
    # print(f"{i}番ノードからの各ノードへの最短距離は{visited}である")
for l in distance:
    print(l)
### BUGGY CODE ###

N=int(input())
history=[]
for i in range(N):
  history.append(int(input()))
history=sorted(history)
print(sum([history.count(n)%2 for n in list(set(history))]))

### FIXED CODE ###

N=int(input())
history=[]
for i in range(N):
  history.append(int(input()))
history=sorted(history)
nums=[]
for i in range(N):
  if i==0:
    nums.append(1)
  else:
    if history[i]==history[i-1]:
      nums[-1]+=1
    else:
      nums.append(1)
print(sum([n%2 for n in nums]))
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
board = [list(input().strip()) for i in range(h)]

white = [[False] * w for i in range(h)]

q = deque()
for y in range(h):
    for x in range(w):
        if board[y][x] == ".":
            white[y][x] = True
        else:
            q.append((x, y, 0))

step = 0
while len(q) > 0:
    x, y, step = q.popleft()
    for n_x, n_y in [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]:
        if 0 <= n_x and n_x < w and 0 <= n_y and n_y < h:
            if white[n_y][n_x]:
                q.append((n_x, n_y, step+1))
                white[n_y][n_x] = False

print(step)


### FIXED CODE ###

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

def main():
    H, W = map(int, input().split())

    INF = int(1e7)
    a = np.array([list(map(lambda x: 0 if x=="#" else INF, list(input().strip()))) for i in range(H)])

    for i in range(H-1):
        a[i+1] = np.minimum(a[i] + 1, a[i+1])
    for i in range(H-1, 0, -1):
        a[i-1] = np.minimum(a[i] + 1, a[i-1])
    
    for i in range(W-1):
        a[:, i+1] = np.minimum(a[:, i] + 1, a[:, i+1])
    for i in range(W-1, 0, -1):
        a[:, i-1] = np.minimum(a[:, i] + 1, a[:, i-1])

    print(np.max(a))

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

r1,c1,r2,c2 = map(int,input().split())

MOD = 10**9+7
MAXN = 10**6+5
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD

def comb(n,r):
    r = min(r,n-r)
    ret = 1
    for i in range(r):
        ret *= (n-i)
        ret *= inv[i+1]
    ret %= MOD
    return ret

ans = 0
a = comb(r1+c1-1, r1)
b = comb(r1+c2, r1)
for r in range(r1,r2+1):
    a *= (r+c1) * inv[r+1]
    b *= (r+c2+1) * inv[r+1]
    ans += b-a
ans %= MOD
print(ans)

### FIXED CODE ###

r1,c1,r2,c2 = map(int,input().split())

MOD = 10**9+7
MAXN = 2*10**6+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 0
for r in range(r1,r2+1):
    ans += ncr(r+c2+1, r+1) - ncr(r+c1, r+1)
ans %= MOD
print(ans)
### BUGGY CODE ###

import math

def ncr_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


MOD = 1000000007
n, a, b = list(map(int, input().split()))

res = 2 ** n - 1

res = res - ncr_count(n, a) - ncr_count(n, b)

print(res%MOD)

### FIXED CODE ###

MOD = 1000000007
n, a, b = list(map(int, input().split()))

res = pow(2, n, MOD) - 1

dpa = {}
dpb = {}
factriala = 1
factrialb = n
for i in range(1, max(a, b)+1):
  if i in [a, b]:
    dpb[i] = factrialb
  factriala *= i
  factriala %= MOD
  factrialb *= n-i
  factrialb %= MOD
  if i in [a, b]:
    dpa[i] = factriala

def ncr_count(r):
  return dpb[r] * pow(dpa[r], MOD-2, MOD)

res = res - ncr_count(a) - ncr_count(b)

print(res%MOD)
### BUGGY CODE ###

import heapq
def main():
	N, M = map(int, input().split())
	A = list(map(int, input().split()))
	heapq.heapify(A)
	BC = [0]*M
	for i in range(M):
		BC[i] = list(map(int, input().split()))
	BC.sort(key = lambda x: -x[1])
	for i in range(M):
		if A[0] > BC[i][1]:
			break
		for _ in range(BC[i][0]):
			if A[0] > BC[i][1]:
				break
			heapq.heappop(A)
			heapq.heappush(A, BC[i][1])
	print(sum(A))


if __name__ == '__main__':
	main()

### FIXED CODE ###

import heapq
def main():
	N, M = map(int, input().split())
	A = list(map(int, input().split()))
	heapq.heapify(A)
	BC = [0]*M
	for i in range(M):
		BC[i] = list(map(int, input().split()))
	BC.sort(key = lambda x: -x[1])
	for B, C in BC:
		if A[0] >= C:
			break
		for _ in range(B):
			if A[0] >= C:
				break
			heapq.heapreplace(A, C)
	print(sum(A))


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

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
  a[a.index(max(a))] //= 2
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i*-1 for i in a]
heapq.heapify(a)
for i in range(m):
    x = ((-1) * heapq.heappop(a)) //2
    heapq.heappush(a, -x)
print(-sum(a))
### BUGGY CODE ###

def check(num, N): #Nからnumが作れるならreturn 1
    length = len(N)

    get_target = 0
    for i in range(length):
        if get_target == 0 and N[i] == num[0]:
            get_target = 1
            # print("target1", num)
        elif get_target == 1 and N[i] == num[1]:
            get_target = 2
            # print("target2", num)
        elif get_target == 2 and N[i] == num[2]:
            get_target = 3
            # print("target3", num)
    
    if get_target == 3:
        # print(num)
        return 1
    else:
        return 0


N = int(input())
S = input()

counter = 0
for i in range(1000):
    str_i = str(i)
    while len(str_i) <3:
        str_i = "0" + str_i
    
    counter += check(str_i, S)
print(counter)


### FIXED CODE ###

def check(num, N): #Nからnumが作れるならreturn 1
    length = len(N)

    get_target = 0
    for i in range(length):
        if get_target == 0 and N[i] == num[0]:
            get_target = 1
            # print("target1", num)
        elif get_target == 1 and N[i] == num[1]:
            get_target = 2
            # print("target2", num)
        elif get_target == 2 and N[i] == num[2]:
            get_target = 3
            # print("target3", num)
    
    if get_target == 3:
        # print(num)
        return 1
    else:
        return 0


N = int(input())
S = input()

counter = 0
for i in range(1000):
    str_i = str(i)
    while len(str_i) <3:
        str_i = "0" + str_i
    
    counter += check(str_i, S)
print(counter)
### BUGGY CODE ###

i = list(map(int,input().split()))
n = i[0]
l = i[1]

alist = []
i = 1

while i < n+1:
  x = l + i - 1
  alist.append(x)
  i =+ 1
  
  

k = 0
m = 0
while k < n-1:
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  k =+ 1
  
  
print(sum(alist) - alist[m])



  
  
  

### FIXED CODE ###

i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
j = 0
 
for j in range(n):
  x = l + j
  alist.append(x)
  
   
k = 0
m = 0
for k in range(n-1):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
print(sum(alist) - alist[m])
### BUGGY CODE ###

N=int(input())
a = list(map(int, input().split()))
n = list(range(1,N+1))
for i in range(N):
    print(n[a.index(i+1)] )

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
  b[a[i]-1]=str(i+1)
print(" ".join(b))
### BUGGY CODE ###

def eratosthenes(N):
    from collections import deque
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    ret = []
    for i in range(N+1):
        if work[i]:
            ret.append(i)
            for j in range(2* i, N+1, i):
                work[j] = False
    return ret

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def main():
    N = int( input())
    A = list( map( int, input().split()))
    # A.sort()
    g = A[0]
    for a in A:
        g = gcd(a, g)
    if g > 1:
        print("not coprime")
        return
    # for i in range(N-1):
    #     if A[i] == A[i+1]:
    #         print("setwise coprime")
    #         return
    E = eratosthenes(10**3)
    for e in E:
        cnt = 0
        for i in range(N):
            if A[i]%e == 0:
                cnt += 1
            while A[i]%e == 0:
                A[i] //= e
        if cnt > 1:
            print("setwise coprime")
            return
    A.sort()
    for i in range(N-1):
        if A[i] == A[i+1] and A[i] > 1:
            print("setwise coprime")
            return
    print("pairwise coprime")
    
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

from math import gcd
def eratosthenes(N):
    from collections import deque
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    ret = []
    for i in range(N+1):
        if work[i]:
            ret.append(i)
            for j in range(2* i, N+1, i):
                work[j] = False
    return ret

# def gcd(a, b):
#     while b != 0:
#         a, b = b, a % b
#     return a

def main():
    N = int( input())
    A = list( map( int, input().split()))
    g = A[0]
    for a in A:
        g = gcd(a, g)
    if g > 1:
        print("not coprime")
        return
    E = eratosthenes(10**3)
    EE = [0]*len(E)
    R = []
    for a in A:
        for i, e in enumerate(E):
            if a%e == 0:
                if EE[i] > 0:
                    print("setwise coprime")
                    return
                EE[i] = 1
            while a%e == 0:
                a //= e
        if a > 1:
            R.append(a)
    R.sort()
    for i in range(len(R)-1):
        if R[i] == R[i+1]:
            print("setwise coprime")
            return
    print("pairwise coprime")
    
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

### FIXED CODE ###

H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))
### BUGGY CODE ###

a, b, k = map(int, input().split())
for x in range(a, b+1):
    if (x - a) < k or (b - x) < k:
        print(x)

### FIXED CODE ###

a, b, k = map(int, input().split())
nums = set()
for i in range(k):
    if i > (b - a):
        break

    nums.add(a + i)
    nums.add(b - i)

for x in sorted(list(nums)):
    print(x)
### BUGGY CODE ###

n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for third in lsorted[second+1:]:
            if lsorted[longest] - lsorted[second] - third >= 0:                
                break
            else:
                ans += 1

print(ans)

### FIXED CODE ###

from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

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

N,K=map(int,input().split())
P=tuple(map(int,input().split()))
cnt=0.0
for i in range(N-K+1):
  S=sum(P[i:i+K])
  S=(S+K)/2.0
  cnt=max(cnt,S)
print(cnt)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K,N+1):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)