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

L, N = (int(i) for i in input().split())
X = [int(input()) for _ in range(N)]
X.insert(0, 0)

d = {("", 0, 0, 0): 0}
for _ in range(N):
    d_ = {}
    for (root, p, l, r), w in d.items():
        d_[(root+"R", X[l+1], l+1, r)] = w + X[l+1] - p
        d_[(root+"L", X[-(r+1)] - L, l, r+1)] = w + (L - X[-(r+1)]) + p
    d = d_
    # print(d)
print(max(d.items(), key=lambda x: x[1])[1])


### FIXED CODE ###

import math

L, N = (int(i) for i in input().split())
X = [int(input()) for _ in range(N)]
X.insert(0, 0)

X_r = [L - i for i in reversed(X)]
X_r.insert(0, 0)
X_r.pop()

def lsum(l):
    s = 0
    for i in l:
        s += i
        yield s

X_sum = list(lsum(X))
X_r_sum = list(lsum(X_r))

def f_l(p, n):
    N_tmp = N - n
    a = N_tmp // 2
    if N_tmp == 0:
        return 0
    elif N_tmp % 2 == 0:
        return 2 * X_sum[a] + X_r_sum[a + n] + X_r_sum[a + n - 1] - 2 * X_r_sum[n] + p
    else:
        return X_sum[a+1] + X_sum[a] + 2 * X_r_sum[a + n] - 2 * X_r_sum[n] + p


def f_r(p, n):
    N_tmp = N - n
    a = N_tmp // 2
    if N_tmp == 0:
        return 0
    elif N_tmp % 2 == 0:
        return 2 * X_r_sum[a] + X_sum[a + n] + X_sum[a + n - 1] - 2 * X_sum[n] + p
    else:
        return X_r_sum[a+1] + X_r_sum[a] + 2 * X_sum[a + n] - 2 * X_sum[n] + p

max_l = max(X[i] + f_r(X[i], i) for i in range(1, N+1))
max_r = max(X_r[i] + f_l(X_r[i], i) for i in range(1, N+1))

print(max(max_l, max_r))
### BUGGY CODE ###

import networkx as nx

N, M = map(int,input().split())
G = nx.Graph()

for _ in range(M):
    A, B = map(int,input().split())
    G.add_edge(A, B)

print_str = 'Yes\n'
for i in range(2, N + 1):
    ans = nx.shortest_path(G, source = i, target = 1)
    print_str += (str(ans[1]) + '\n')
        
print(print_str[:-1])

### FIXED CODE ###

from collections import deque
N, M = map(int,input().split())
graph = [[] for i in range(N + 1)]
for _ in range(M):
    A, B = map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)

queue = deque([1]) 
flag = [-1] * (N + 1)

while queue: 
    node = queue.popleft()
    children = graph[node] 
    for child in children:
        if flag[child] == -1:
            flag[child] = node
            queue.append(child)

if -1 in flag[2:]:
    print('No')
else:
    print('Yes')
    print(*flag[2:], sep='\n')
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

a = sorted(a)
#print(a)
count = 0
while len(a)>=1:
    aa = a.pop(0)
    if len(a)>=1 and a[0] == aa:
        while a[0] == aa:
            a.pop(0)
            if len(a) == 0:
                break
        continue
    #print("after popped aa: ",a)
    #print("aa: ",aa)
    count += 1
    i = 0
    num = 0
    a_len = len(a)
    while num < a_len:
        if a[i] % aa == 0:
            #print("remove: ",a[i])
            a.remove(a[i])
            #print("a -> ",a)
            num += 1
        else:
            i += 1
            num += 1
        #print("i, num == ",i, num)
print(count)


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
count = 0

a = sorted(a)

max = a[len(a)-1]
line = [0]*(max+1)

for x in a:
    line[x] += 1
    
for x in a:
    if line[x] == 0:
        continue
    xx = x * 2
    j = 3
    while xx <= max:
        if line[xx] != 0:
            line[xx] = 0
        xx = x * j
        j += 1
for i in range(max+1):
    if line[i] == 1:
        count += 1
print(count)
### BUGGY CODE ###

N = int(input())

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_num_letter = max(num_letter)
max_letter = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])
### BUGGY CODE ###

A, B, K = map(int, input().split())


for i in range(K):
    if A >0:
        A -= 1
    elif A==0 and B>0:
        B -= 1
    else:
        pass
    
print(A, B)


### FIXED CODE ###

A, B, K = map(int, input().split())
 
if K<=A:
    ansa=A-K
    ansb=B
elif K>A and K<=A+B:
    ansa=0
    ansb=B-(K-A)
else:
    ansa=0
    ansb=0

print(ansa, ansb)
### BUGGY CODE ###

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

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

border = 2
nborder = 0
eaten = n
cnt = 1
ans = 0
after1 = 1
after3 = 2

while x > eaten:
    if cnt == border:
        if nborder == n-1: break
        eaten += nborder
        nborder += 1
        border = border*2 + 2
        after1 = nborder
    elif (cnt-1) % 4 == 0:
        ans += min(x-eaten,3)
        eaten += 3
    elif (cnt-1) % 4 == 1:
        eaten += after3
        after1 = after3
    elif (cnt-1) % 4 == 2:
        ans += 1
        eaten += 1
    elif (cnt-1) % 4 == 3:
        eaten += after1
        after3 = after1

    cnt += 1


print(ans)


### FIXED CODE ###

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

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

numP_N = [0]*N
numPB_N = [0]*N
numP_N[0] = 3
numPB_N[0] = 5
for i in range(1,N):
    numP_N[i] = numP_N[i-1] * 2 + 1
    numPB_N[i] = numPB_N[i-1] * 2 + 3

def rec(n, x):
    if n == 1:
        ans_1 = [0,0,1,2,3,3]
        return ans_1[x]

    if x == numPB_N[n-1]:
        return numP_N[n-1]

    elif x > numPB_N[n-2] + 2:
        return numP_N[n-2] + 1 + rec(n-1, x-numPB_N[n-2] - 2)

    elif x == numPB_N[n-2] + 2:
        return numP_N[n-2] + 1

    elif x == numPB_N[n-2] + 1:
        return numP_N[n-2]

    elif x < numPB_N[n-2] + 1:
        return rec(n-1, x-1)

print(rec(N,X))
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = list(int(input()) for i in range(Q))
for i in range(N):
    if Q - A.count(i + 1) < K:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

from collections import Counter

N, K, Q = map(int, input().split())
A = list(int(input()) for i in range(Q))
c = Counter(A)
for i in range(N):
    if Q - c[i + 1] < K:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

S = list(input())
T = list(input())

dp = [[0 for i in range(len(S)+1)] for j in range(len(T)+1)]

for i in range(1,len(T)+1):
    for j in range(1,len(S)+1):
        if T[i-1]==S[j-1]:
            dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j-1],dp[i-1][j])
        else:
            dp[i][j]=max(dp[i-1][j-1],dp[i][j-1],dp[i-1][j])
    # print(dp)


i = len(S)
j = len(T)
ans = []
while (i>0  and j>0):
    if dp[j][i] == dp[j-1][i]:
        j -= 1
    elif dp[j][i] == dp[j][i-1]:
        i -= 1
    else:
        ans.append(T[j-1]) 
        i -= 1
        j -= 1


print("".join(reversed(ans)))

### FIXED CODE ###

S = list(input())
T = list(input())

dp = [[0 for i in range(len(S)+1)] for j in range(len(T)+1)]

for i in range(1,len(T)+1):
    for j in range(1,len(S)+1):
        if T[i-1]==S[j-1]:
            dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j-1],dp[i-1][j])
        else:
            dp[i][j]=max(dp[i-1][j-1],dp[i][j-1],dp[i-1][j])
    # print(dp)


i = len(S)
j = len(T)
ans = []
while (i>0  and j>0):
    if dp[j][i] == dp[j-1][i]:
        j -= 1
    elif dp[j][i] == dp[j][i-1]:
        i -= 1
    else:
        ans.append(T[j-1]) 
        i -= 1
        j -= 1


print("".join(reversed(ans)))
### BUGGY CODE ###


def main():
    N,M =list(map( int,input().split()))
    arr = [[1 for i in range(N+2)] for j in range(M+3)]
    ans = 0
    
    for y in range(1,N+1):
        for x in range(1,M+1):
                arr[x][y] = 0 if arr[x][y] else 1 
                arr[x-1][y] = 0 if arr[x-1][y] else 1 
                arr[x][y-1] = 0 if arr[x][y-1] else 1 
                arr[x-1][y-1] = 0 if arr[x-1][y-1] else 1 
                arr[x+1][y] = 0 if arr[x+1][y] else 1 
                arr[x][y+1] = 0 if arr[x][y+1] else 1 
                arr[x+1][y+1] = 0 if arr[x+1][y+1] else 1
                arr[x+1][y-1] = 0 if arr[x+1][y-1] else 1
                arr[x-1][y+1] = 0 if arr[x-1][y+1] else 1
                
    
    for y in range(1,N+1):
        for x in range(1,M+1):
            if arr[x][y] == 0:
                ans = ans + 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

N,M = list(map(int,input().split()))
ans = (N-2)*(M-2)
if N == 1 and M == 1:
    ans = 1
elif M == 1:
    ans = abs(N - 2)
print(abs(ans))
### BUGGY CODE ###

from collections import defaultdict
def main():
    n,p=map(int,input().split())
    S=[int(x) for x in list(input().strip())]
    if p==2 or p==5:
        ans=0
        for i,s in enumerate(S):
            if s%p==0:
                ans+=(i+1)
        return ans
    S.reverse()
    d=defaultdict(int)
    tmp=0
    ans=0
    for i,s in enumerate(S):
        tmp+=s*pow(10,i)
        r=tmp%p
        ans+=d[r]
        d[r]+=1
    ans+=d[0]
    return ans
    
if __name__=='__main__':
    print(main())

### FIXED CODE ###

from collections import defaultdict
def main():
    n,p=map(int,input().split())
    S=[int(x) for x in tuple(input().strip())]
    if p==2 or p==5:
        ans=0
        for i,s in enumerate(S):
            if s%p==0:
                ans+=(i+1)
        return ans
    d=defaultdict(int)
    tmp=0
    digit=1
    ans=0
    for i,s in enumerate(reversed(S)):
        tmp+=s*digit
        digit*=10
        digit%=p
        r=tmp%p
        ans+=d[r]
        d[r]+=1
    ans+=d[0]
    return ans
    
if __name__=='__main__':
    print(main())
### BUGGY CODE ###

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

graph1 = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]

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


# def dfs(v0, v, k):
#     if k == 0:
#         graph2[v0].append((1, v))
#         return
#
#     for i in range(len(graph1[v])):
#         dfs(v0, graph1[v][i][1], k-1)
#
# for i in range(n):
#     dfs(i, i, 3)
#     # print(graph1[i])

for i in range(n):
    q = [(i, 3)]
    idx = 0
    while True:
        if idx == len(q):
            break
        v, c = q[idx]
        idx += 1
        if c == 0:
            graph2[i].append((1, v))
            continue
        for _, j in graph1[v]:
            q.append((j, c-1))



# for i in range(n):
#     print(i)
#     for _, v in graph1[i]:
#         print(" ->", v)
#
#
for i in range(n):
    graph2[i] = list(set(graph2[i]))
# print()
# for i in range(n):
#     print(graph2[i])


s, t = map(int, input().split())
s -= 1
t -= 1


from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist
    # dist = [costs to nodes]

inf = float('inf')
dist = dijkstra(graph2, n, s)
if dist[t] == inf:
    print(-1)
else:
    print(dist[t])


### FIXED CODE ###

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

graph1 = [[] for _ in range(n*3)]

for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph1[u*3+0].append(v*3+1)
    graph1[u*3+1].append(v*3+2)
    graph1[u*3+2].append(v*3+0)

s, t = map(int, input().split())
s -= 1
t -= 1
s = s*3
t = t*3

from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    NextCost = 1
    while heap:
        cost,thisNode = heappop(heap)
        for NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist
    # dist = [costs to nodes]

inf = float('inf')
dist = dijkstra(graph1, n*3, s)
if dist[t] == inf:
    print(-1)
else:
    print(dist[t]//3)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

c = 0
for r in range(N + 1):
	for g in range(N + 1):
		f = (N - r * R - g * G) % B
		b = (N - r * R - g * G) // B
		if not f and (0 <= b) and (N == (r * R + g * G + b * B)): 
			#print(r, g, b)
			c += 1
print(c)


### FIXED CODE ###

R, G, B, N = map(int, input().split())

c = 0
for r in range(0, N + 1, R):
	for g in range(0, N + 1, G):
		if N < r + g:
			break
		d = N - r - g
		if not d % B:
			c += 1
	
"""
	for g in range(N + 1):
		if N < r * R + g * G:
			break
		x = (N - r * R - g * G)
		if not (x % B) and (0 <= (x // B)):
			#print(r, g, b)
			c += 1
"""
print(c)
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0

for i in range(k+1):
    if i == s:
        count += 1
        break

    for j in range(k+1):
        if (i+j) == s:
            count += 1
            break

        for t in range(k+1):
            if (i+j+t) == s:
                count += 1
                break

print(count)

### FIXED CODE ###

k,s = map(int,input().split())
count = 0

for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if z >= 0 and z <= k:
            count += 1

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

n = int(input())
l = [int(i) for i in input().split()]

from itertools import combinations
print(len([True for a, b, c in combinations(l, 3) if (a < b + c and b < a + c and c < a + b)]))


### FIXED CODE ###

n = int(input())
l = sorted([int(i) for i in input().split()])

from bisect import bisect_left
total = 0
for i in range(n):
    for j in range(i+1, n):
        total += (bisect_left(l, l[i] + l[j]) - j - 1)

print(total)
### BUGGY CODE ###

n,m=map(int,input().split())
c=1
if n==1:
    print(m)
else:
    for i in range(m//n,0,-1):
        if m%i==0:
            print(i)
            break

### FIXED CODE ###

n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
            if m//i>= n:
                print(i)
                break
solve()
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10000000)
n,m = map(int,input().split())
p = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(m)]

Graph = [[] for _ in range(n)]
for x,y in xy:
    Graph[x-1].append(y-1)
    Graph[y-1].append(x-1)

check = [False for _ in range(n)]
def dfs(g,start,c,goal):
    c[start] = True
    if start == goal:
        return True
    for u in g[start]:
        if c[u]:
            continue
        if dfs(g,u,c,goal):
            return True
ans = 0
for i in range(n):
    c = check.copy()
    if dfs(Graph,i,c,p.index(i+1)):
        ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3


n,m = map(int,input().split())
p = list(map(int,input().split()))
for i in range(n):
    p[i] -= 1

#連結成分に属するかどうかを見るときはUnion-Findを用いる
#根(属するクラス)を返す関数
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
#同じクラスに属するかどうかを返す関数
def same(x,y):
    return root(x) == root(y)
#木を結合する関数
def union(x,y):
    x = root(x)
    y = root(y)
    #高さの高いほうに低いほうを結合
    if rank[x] < rank[y]:
        par[x] = y#xの親(属するクラス)をyとする
    else:
        par[y] = x
        if rank[x] == rank[y]:#高さが同じ場合
            rank[x] += 1#高さは1つ増える
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    #swapできる頂点は同じ木にして同じ連結成分にする
    if not same(x-1,y-1):
        union(x-1,y-1)

ans = 0
for i in range(n):
    #p[i]とiが同じ連結成分ならばans+1
    if root(p[i]) == root(i):
        ans += 1
print(ans)
### BUGGY CODE ###

x,k,d=map(int,input().split())
sa=abs(x)//d
ans=x
if sa>=k:
  ans=abs(x)-d*k
else:
  for i in range(k-sa):
    if abs(ans-d)<abs(ans+d):
      ans=abs(ans-d)
    elif abs(ans-d)>abs(ans+d):
      ans=abs(ans+d)
    else:
      if (k-i)%2==1:
        ans=d
      break
print(ans)

### FIXED CODE ###

x,k,d=map(int,input().split())
x=abs(x)
sa=x//d
ans=x
pbk,mbk=0,0
bk1,bk2,bk3=1,1,1
mansbk,pansbk=0,0
if sa>=k:
  ans=x-d*k
else:
  ans=x-d*sa
  k=k-sa
  for i in range(k):
    mansbk=abs(ans-d)
    pansbk=abs(ans+d)
    if mansbk!=pansbk:
      ans=min(mansbk,pansbk)
      if bk3!=1:
        bk1=min(mansbk,pansbk)
        bk2=max(mansbk,pansbk)
        ans=mbk if (k-i)%2==0 else bk1
        break
      else:
        bk3=max(mansbk,pansbk) 
    else:
      ans=0 if (k-i)%2==0 else d
      break
    pbk=max(mansbk,pansbk)
    mbk=min(mansbk,pansbk)
print(ans)
### BUGGY CODE ###

import bisect
import heapq

n, m = map(int, input().split())
a_list = []
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        a_list.append([a, b])
a_list.sort()
a_list_1 = [aa[0] for aa in a_list]
a_list_2 = [-aa[1] for aa in a_list]
ans = 0
heap_list = []
for i in range(1, m + 1):
    k = bisect.bisect_right(a_list_1, i) - 1
    if k >= 0:
        for aa in a_list_2[:k+1]:
            heapq.heappush(heap_list, aa)
        del a_list_1[:k+1], a_list_2[:k+1]
    if len(heap_list) > 0:
        ans -= heapq.heappop(heap_list)
print(ans)

### FIXED CODE ###

from collections import defaultdict
import heapq

a_dict = defaultdict(lambda: [])
n, m = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a_dict[a].append(-b)
ans = 0
heap_list = []
for i in range(1, m + 1):
    for aa in a_dict[i]:
        heapq.heappush(heap_list, aa)
    if len(heap_list) > 0:
        ans -= heapq.heappop(heap_list)
print(ans)
### BUGGY CODE ###

n=int(input())
arr=list(map(int,input().split()))
l=int(input())
pos=0
dbl=[[0]*(n+1)]
for i in range(n):
  for j in range(pos,n):
    if arr[j]-arr[i]>l:
      dbl[0][i+1]=j
      pos=j
      break
  else:
    dbl[0][i+1]=n
for _ in range(20):
  tmp=[0]*(n+1)
  for i in range(n+1):
    tmp[i]=dbl[-1][dbl[-1][i]]
  dbl.append(tmp)
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  l=0
  r=b-a+1
  while r-l!=1:
    mid=(l+r)//2
    tmp=a
    for i in range(20):
      if mid&(1<<i):
        tmp=dbl[i][tmp]
    if tmp>=b:
      r=mid
    else:
      l=mid
  print(r)

### FIXED CODE ###

import bisect
import sys
input=sys.stdin.readline

def calc():
  n=int(input())
  arr=list(map(int,input().split()))
  l=int(input())
  pos=0
  dbl=[[0]*(n+1)]
  for i in range(n):
      dbl[0][i+1]=bisect.bisect_right(arr,arr[i]+l)
  for _ in range(n.bit_length()-1):
    tmp=[0]*(n+1)
    for i in range(n+1):
      tmp[i]=dbl[-1][dbl[-1][i]]
    dbl.append(tmp)
  q=int(input())
  for _ in range(q):
    a,b=map(int,input().split())
    if a>b:
      a,b=b,a
    l=0
    r=b-a+1
    while r-l!=1:
      mid=(l+r)//2
      tmp=a
      for i in range(mid.bit_length()):
        if mid&(1<<i):
          tmp=dbl[i][tmp]
      if tmp>=b:
        r=mid
      else:
        l=mid
    print(r)
calc()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int,input().split()))

B = [0 for _ in range(N)]
for i in A:
    B[i-1] += 1
B = tuple(sorted(B, reverse = True))

for i in range(N):
    ans = 0
    C = list(B)
    while C[i] != 0:
        for j in range(i+1):
            C[j] -= 1
        C = sorted(C, reverse = True)
        ans += 1
    print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import Counter
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))

B = list(Counter(A).values())

C = [0] * N 
for i in B:
    C[i-1] += 1

F = list(accumulate(C))

S = [0] * N
f = [0] * N
S[0] = f[0] = sum(C) 
for i in range(2, N+1):
    S[i-1] = (S[i-2] + C[i-1] + S[0] - F[i-1] ) 
    f[i-1] = S[i-1] / i

f.sort()
n = 0     
K = 1
    
while K != N+1:
    if K <= f[n]:
        print(N-n)
        K += 1
    else:
        n += 1
    if n == N:
        for i in range(N-K+1):
            print(0)
        K = N+1
### BUGGY CODE ###

input()
A = list(map(int,input().split(' ')))
x = A[0]
for a in A[1::]:
    x=x*a
    A.pop(0) 
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

### FIXED CODE ###

N = input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
    exit()
x = 1
for a in A:
    x *= a
    if x > 1000000000000000000:
        print(-1)
        exit()
print(x)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 1
for a in A:
    ans *= a
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
### BUGGY CODE ###

n=int(input())
ide_ele=n
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
segfunc=min

def init(init_val):
  for i in range(n):
    seg[i+num-1]=init_val[i]    
    for i in range(num-2,-1,-1) :
      seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
  k+=num-1
  seg[k]=x
  while k+1:
    k=(k-1)//2
    seg[k]=segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
  if q<=p:
    return ide_ele
  p+=num-1
  q+=num-2
  res=ide_ele
  while q-p>1:
    if p&1==0:
      res=segfunc(res,seg[p])
    if q&1==1:
      res=segfunc(res,seg[q])
      q-=1
    p=p//2
    q=(q-1)//2
  if p==q:
    res=segfunc(res,seg[p])
  else:
    res=segfunc(segfunc(res,seg[p]),seg[q])
  return res
init_val=[int(i) for i in input().split()]
init(init_val)
ans=0
for i in range(n):
  for j in range(i,n):
    ans+=query(i,j+1)
print(ans)

### FIXED CODE ###

n=int(input())
A=[int(i) for i in input().split()]

Ans=[0]*n
Ans[0]=1
Stack=[[A[0],1]]
for i in range(1,n):
  a=A[i]
  b,ct_b=Stack.pop()
  ct=1
  while b>a and Stack:
    ct+=ct_b
    b,ct_b=Stack.pop()
  if b<a:
    Stack.append([b,ct_b])
    Stack.append([a,ct])
  else:
    Stack.append([a,ct+ct_b])
    ct+=ct_b
  Ans[i]=ct
RA=A[::-1]
Ans_R=[0]*n
Ans_R[0]=1
Stack=[[RA[0],1]]
for i in range(1,n):
  a=RA[i]
  b,ct_b=Stack.pop()
  ct=1
  while b>a and Stack:
    ct+=ct_b
    b,ct_b=Stack.pop()
  if b<a:
    Stack.append([b,ct_b])
    Stack.append([a,ct])
  else:
    Stack.append([a,ct+ct_b])
    ct+=ct_b
  Ans_R[i]=ct  
Ans_R=Ans_R[::-1]
ans=0
for i in range(n):
  ans+=(A[i]*Ans[i]*Ans_R[i])
print(ans)
### BUGGY CODE ###

from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)

n = int(input())
s = []
for i in range(n):
    s.append(input())

ans = 0
roop = True

while s != []:
    string = s.pop()
    s_new = []
    temp = 1
    for mojiretu in s:
        if verify_anagrams(string, mojiretu):
            temp += 1
        else:
            s_new.append(mojiretu)
    ans += temp * (temp-1) // 2
    s = s_new.copy()

print(ans)

### FIXED CODE ###

n = int(input())
lst = []
dic = {}
for i in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    if s not in dic.keys():
        dic[s] = 1
    else:
        dic[s] += 1

ans = 0
for i in dic.values():
    ans += i * (i-1) // 2

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

import copy,numpy
n=int(input())
A=[int(input()) for _ in range(n)]
for i in range(len(A)):
    B=copy.copy(A)
    del B[i]
    print(numpy.max(B))

### FIXED CODE ###

n=int(input())
A=[int(input()) for _ in range(n)]
ma=max(A)
ma_i=A.index(ma)
for i in range(n):
    if i==ma_i:
        print(max(A[:i]+A[i+1:]))
    else:
        print(ma)