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

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

dp = [[[0 for _ in range(2501)] for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for i in range(N):
    for a in range(N):
        for p in range(2500 - x[i]):
            dp[i + 1][a + 1][p + x[i]] += dp[i][a][p]
            dp[i + 1][a][p] += dp[i][a][p]


ret = 0
for a in range(1, N+1):
    ret += dp[N][a][A * a]

print(ret)

### FIXED CODE ###

import numpy as np

N, A = map(int, input().split())
X = [0] + list(map(int, input().split()))
NX = N * max(X + [A])

dp = np.zeros((N + 1, 2 * NX + 1), dtype=int)

dp[0][NX] = 1

for j in range(1, N + 1):
    y = X[j] - A
    for t in range(2 * NX + 1):
        if 0 <= t - y < 2 * NX:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y]
        else:
            dp[j][t] = dp[j - 1][t]

print(dp[N][NX] - 1)
### BUGGY CODE ###

import collections
n=int(input())
strs = [input() for i in range(n)]

str_dict = [0]*(n)

for i in range(n):
    str_dict[i] = collections.Counter(strs[i])

ans = 0

for i in range(n):
    for j in range(n):
        if str_dict[i] == str_dict[j] and i != j:
            ans += 1

print(int(ans/2))

### FIXED CODE ###

import collections
n = int(input())
strs = ["".join(sorted(input())) for _ in range(n)]
d = collections.Counter(strs)
ans=0
for x in d.values():
  ans += x*(x-1)/2

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

n=int(input())

ans=0

a=[]
b=[]

for _ in range(n):
    x=int(input())
    a.append(x)
    b.append(x)
b.sort()

cnt=0
for i,v in enumerate(a):
    if i%2 != (b.index(v))%2:
        cnt+=1
print(cnt//2)

### FIXED CODE ###

n=int(input())

ans=0

a=[]
b=[]

for _ in range(n):
    x=int(input())
    a.append(x)
    b.append(x)
b.sort()

dic={}
for i,v in enumerate(b):
    dic[v]=i%2

cnt=0
for i,v in enumerate(a):
    if i%2 != dic[v]:
        cnt+=1
print(cnt//2)
### BUGGY CODE ###

import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
result = [0]*N
tmp = 0
for i in range(N):
  tmp = A.pop(i)
  result[i] = reduce(fractions.gcd, A)
  A.insert(i,tmp)

print(max(result))

### FIXED CODE ###

import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
### BUGGY CODE ###

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

allhiyatoi = []
for i in range(N):
    temp = list(map(int,input().split()))
    allhiyatoi.append(temp)

allhiyatoi.sort()

reward = 0
for i in range(M+1):
    today_hiya_idx = -1
    today_reward = 0
    for j,hiya in enumerate(allhiyatoi):
        if hiya[0]>i:
            break
        if today_reward <= hiya[1]:
            today_hiya_idx = j
            today_reward = hiya[1]
    
    reward += today_reward
    if today_hiya_idx != -1:
        allhiyatoi[today_hiya_idx][1] = -1

print(reward)

### FIXED CODE ###

from heapq import heappush, heappop
 
N,M = map(int,input().split())

allhiyatoi = [[] for j in range(M+1)]
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] > M:
        continue
    allhiyatoi[temp[0]].append(temp[1])
 
reward = 0
Q = []
for i in allhiyatoi:
    for j in i:
        heappush(Q,j*-1)
    if len(Q) == 0:
        continue
    reward -= (heappop(Q))

print(reward)
### BUGGY CODE ###

n = int(input())
s = input()
res = 0
for i in range(0, n):
    for j in range(i+1,n):
        if(j > n):
            break
        for k in range(j+1,n):
            if(k > n):
                break
            if(s[i] != s[j] and s[i] != s[k] and s[j] != s[k] and (j - i ) != (k-j)):
                res += 1

print(res)

### FIXED CODE ###

import collections

n = int(input())
s = input()
res = 0
# for i in range(0, n):
#     for j in range(i+1,n):
#         if s[i] != s[j]:
#             for k in range(j+1,n):
#                 if j-i!=k-j and s[i] != s[k] and s[j] != s[k]:
#                     res += 1
#
# print(res)
num = collections.Counter(s)
# print(num)
num_r = num["R"]
num_g = num["G"]
num_b = n - num_r - num_g
count_2 = 0
for x in range(1,int(n/2)+1):
    for i in range(n-2*x):
        # print(x)
        # print(i)
        # print()
        if (i + 2 * x < n and s[i] != s[i + x] and s[i + x] != s[i + 2 * x] and s[i] != s[i + 2 * x] ):
            count_2 += 1
            # print(x)
            # print(i)
            # print()

res = num_r * num_g * num_b - count_2
# print(num_r)
# print(num_g)
# print(num_b)
print(res)
### BUGGY CODE ###

import collections
N=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(N):
    x=A[i]
    A[i]=0
    c=collections.Counter(A)
    for j in c.values():
        sum+=j*(j-1)/2
    print(int(sum))
    sum=0
    A[i]=x

### FIXED CODE ###

import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

c=collections.Counter(A)
list=c.values()
result=0

for x in list:
    if x>1:
        result+=cmb(x,2)
for y in c.keys():
    c[y]=result-(c[y]-1)

for z in A:
    print(c[z])
### BUGGY CODE ###

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

s = 0
S = 0

for i in range(n):
    s = S
    S += ls_a[i]
    if S > sum(ls_a)/2:
        break

print(int(min(abs(sum(ls_a)/2 - s)*2, abs(sum(ls_a)/2 - S)*2)))

### FIXED CODE ###

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

s = 0
S = 0
half = sum(ls_a)/2

for i in range(n):
    s = S
    S += ls_a[i]
    if S > half:
        break

print(int(min(abs(half - s)*2, abs(half - S)*2)))
### BUGGY CODE ###

import numpy as np
N = int(input())
S = input()

l_r = [i for i, s in enumerate(S) if s=='R']
l_g = [i for i, s in enumerate(S) if s=='G']
l_b = [i for i, s in enumerate(S) if s=='B']

ans = len(l_r)*len(l_g)*len(l_b)

for r in l_r:
  for g in l_g:
    li = np.sort(np.array([r, g]))
    tmp = li[1]*2 -li[0]
    if tmp in l_b:
      ans -= 1
    
    tmp = (li[0]+li[1])/2
    if tmp in l_b:
   	  ans -= 1
      
    tmp = 2*li[0] - li[1]
    if tmp in l_b:
   	  ans -= 1

print(ans)


### FIXED CODE ###

import numpy as np
N = int(input())
S = input()

l_r = set()
l_g = set()
l_b = set()
for i in range(N):
  if S[i]=='R':
    l_r.add(i)
  if S[i]=='G':
    l_g.add(i)
  if S[i]=='B':
    l_b.add(i)

ans = len(l_r)*len(l_g)*len(l_b)

for r in l_r:
  for g in l_g:
    mi = min(r, g)
    ma = max(r, g)
    l = ma - mi
    if ma+l in l_b:
      ans -= 1
    if mi-l in l_b:
      ans -= 1
    if l%2==0 and l//2 + mi in l_b:
      ans -= 1

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

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

_input = sys.stdin.readlines()
array_length = int(_input[0])
array = list(map(int, _input[1].split()))
# print(array_length, array)
# assert array_length == len(array)


def merge(A, left, mid, right):
    global count

    n1 = mid - left
    n2 = right - mid
    L = [0 for _ in range(n1 + 1)]
    R = [0 for _ in range(n2 + 1)]

    for i in range(n1):
        L[i] = A[left + i]

    for j in range(n2):
        R[j] = A[mid + j]

    L[n1], R[n2] = [1e9] * 2
    i, j = 0, 0

    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return None


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


if __name__ == '__main__':
    count = 0
    print(*merge_sort(A=array, left=0, right=array_length))
    print(count)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def merge(A, left, mid, right):
    global count

    L = A[left:mid] + [1e9]
    R = A[mid:right] + [1e9]

    i, j = 0, 0

    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return None


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert array_length == len(array)
    count = 0
    print(*merge_sort(A=array, left=0, right=array_length))
    print(count)
### BUGGY CODE ###

INF = int(1e18)


def main():
    N, *A, = map(int, open(0).read().split())
    ans = 1
    for a in A:
        ans *= a
    print(-1 if INF < ans else ans)
    return


main()


### FIXED CODE ###

INF = int(1e18)


def main():
    N, *A, = map(int, open(0).read().split())
    ans = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        ans *= a
        if INF < ans:
            print(-1)
            break
    else:
        print(ans)
    return


main()
### BUGGY CODE ###

n = input()
l = len(n)
cnt = 0
for i in range(l-3):
    for j in range(i+4, l+1):
        x = int(n[i:j])
        if x % 2019 == 0:
            cnt += 1
print(cnt)

### FIXED CODE ###

from collections import Counter
S = list(map(int, input()))
P = 2019

def solve(S,P):
    S = S[::-1]
    T = [0] * len(S)
    T[0] = S[0] % P
    power = 1
    for i in range(1, len(S)):
        power *= 10
        power %= P
        T[i] = T[i-1] + power * S[i]
        T[i] %= P
    counter = Counter(T)
    return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]
print(solve(S,P))
### BUGGY CODE ###

from collections import deque
def dfs_2d(H,W,M,start,goal):
    que = deque()
    que.append([start[0],start[1]])
    distance = [[-1 for i in range(W)] for j in range(H)]
    dxdy = [[1,0],[-1,0],[0,1],[0,-1]]##4方向

    distance[start[0]][start[1]] = 0

    flag = False
    
    while que:
        x,y = que.popleft()

        if x == goal[0] and y == goal[1]:
            return distance[goal[0]][goal[1]]
        
        for i,j in dxdy:
            dx = x + i
            dy = y + j
            if 0 <= dx <= H-1 and 0 <= dy <= W-1 and M[dx][dy] != "#":
                distance[dx][dy] = distance[x][y] + 1
                que.append([dx,dy])
    return -1

def main():
    H,W = map(int,input().split())
    M = []
    for i in range(H):
        M.append(input())
    ans = 0
    for i in range(H):
        for j in range(W):
            for h in range(H):
                for k in range(W):
                    if M[i][j] != "#" and M[h][k] != "#":
                        start = [i,j]
                        goal = [h,k]
                        ans = max(ans,dfs_2d(H,W,M,start,goal))

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def dfs_2d(H,W,M,start):
    que = deque()
    que.append([start[0],start[1]])
    distance = [[-1 for i in range(W)] for j in range(H)]
    dxdy = [[1,0],[-1,0],[0,1],[0,-1]]##4方向

    distance[start[0]][start[1]] = 0

    flag = False
    
    while que:
        x,y = que.popleft()
        for i,j in dxdy:
            dx = x + i
            dy = y + j
            if 0 <= dx <= H-1 and 0 <= dy <= W-1 and M[dx][dy] != "#" and distance[dx][dy] == -1:
                distance[dx][dy] = distance[x][y] + 1
                que.append([dx,dy])
                
    return max(max(i) for i in distance)

def main():
    H,W = map(int,input().split())
    M = []
    for i in range(H):
        M.append(input())
    ans = 0
    for i in range(H):
        for j in range(W):
            if M[i][j] != "#":
                start = [i,j]
                ans = max(ans,dfs_2d(H,W,M,start))

    print(ans)

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

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

#print(a)
for i in range(m):
    a.sort()
    b,c = map(int,input().split())
    
    count = 0
    for j in range(len(a)):
        e = a[j]
        if count < b:
            if e < c:
                a[j] = c
                #print(c,end=",")
            #else:
                #print(e,end=",")
            count += 1
        #else:
            #print(e,end=",")

    #print()

sum = 0
for v in a:
    sum += v

print(sum)

### FIXED CODE ###

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

d = []

bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append([b,c])

bc = sorted(bc,key=lambda x:x[1],reverse=True)

for elm in bc:
    for i in range(elm[0]):
        d.append(elm[1])
        if len(d) >= n:
            break
    if len(d) >= n:
        break

d.sort()
d.reverse()

#print(a)
#print(d)

sum = 0
ln = len(d)
for i in range(n):
    if i < ln:
        if a[i] < d[i]:
            sum += d[i]
        else:
            sum += a[i]
    else:
        sum += a[i]

print(sum)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [1e10] * N
dp[0] = 0
for i in range(N):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = min([dp[j], dp[i]+abs(h[j]-h[i])])
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [1e10] * N
dp[0] = 0
for i in range(N):
    for j in range(i+1, i+K+1):
        if j >= N:
            break
        dp[j] = min([dp[j], dp[i]+abs(h[j]-h[i])])
print(dp[N-1])
### BUGGY CODE ###

n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
	P[i]-=1
C=list(map(int,input().split()))
ANS=-float('inf')
for i in range(n):
    snp=P[i]
    r=C[snp]
    L=[r]
    c=0
    np=P[snp]
    while True:
        if c==k-1:
            ANS=max(max(L),ANS)
            break
        if np==snp:
            y=k%(c+1)
            m=k//(c+1)
            if y==0:
                ANS=max(max(L),max(L)+(m-1)*L[-1],ANS)
                break
            else:
                ANS=max(max(L),max(max(L[:y]),0)+m*L[-1],ANS)
                break
        r+=C[np]
        L.append(r)
        np=P[np]
        c+=1
print(ANS)


### FIXED CODE ###

n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
	P[i]-=1
C=list(map(int,input().split()))
ANS=-float('inf')
for i in range(n):
    snp=P[i]
    r=C[snp]
    L=[r]
    c=0
    np=P[snp]
    while True:
        if c==k-1:
            ANS=max(max(L),ANS)
            break
        if np==snp:
            y=k%(c+1)
            m=k//(c+1)
            if y==0:
                ANS=max(max(L),max(L)+(m-1)*L[-1],ANS)
                break
            else:
                #print(m,y)
                #print(L)
                ANS=max(max(L),max(max(L[:y]),0)+m*L[-1],ANS)
                break
        r+=C[np]
        L.append(r)
        np=P[np]
        c+=1
print(ANS)
### BUGGY CODE ###

a,b,c,d=map(int,input().split())
ans=-999999999999999999
for i in range(a,b+1):
  for j in range(c,d+1):
    ans=max(ans,i*j)

print(ans)

### FIXED CODE ###

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

q=a*c
w=a*d
e=b*c
r=b*d

ans=max(q,w,e,r)
print(ans)
### BUGGY CODE ###

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


B = sorted(A)
#print(A)
C = []
last = -1
for i in range(N):
    if(last != B[i]):
        C.append(B[i])
        last = B[i]
    else:
        if(len(C)>0):
            del C[-1]



l = []
for e in C:
    status = True
    for p in l:
        if(e % p == 0):
            status = False
    if(status):
        l.append(e)
print(len(l))

### FIXED CODE ###

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


#print(A)

MAX = 10**6+1000
l = [True] * MAX


count = 0
last = -1
mode = 0
for i in range(len(A)):
    e = A[i]
    if(last == e):
        count -= 1
        last = -1
    if(l[e]):
        count += 1
        for j in range(MAX):
            try:
                l[j*e] = False
            except IndexError:
                break
        last = e

    #print(l)

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

h,n=map(int,input().split())
INF=10**9
A=[]; dp=[INF]*(h+10)
for i in range(n):
  x,y=map(int,input().split())
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h):
    index=h if i+a>h else i+a
    x=dp[i]+b; y=dp[index]
    dp[index]=y if y<x else x
print(dp[h])

### FIXED CODE ###

def IN(): return map(int,input().split())
ans = pow(2,31); mod = pow(10,9)+7
h,n=IN()
A=[]; dp=[pow(2,31)]*111111
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h+1111):
    dp[i+a]=min(dp[i+a],dp[i]+b)
for i in range(h,11111):
  ans=min(ans,dp[i])
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = 0
if n % 2 == 1:
  if a.count(0) != 1: flag = 1
  else:
    for i in range(n // 2 + 1):
      if a[i] != 0 and a.count(a[i]) != 2:
        flag = 1
else:
  if a.count(0) != 0: flag = 1
  else:
    for i in range(n // 2 + 1):
      if a.count(a[i]) != 2:
        flag = 1

if flag == 0:
  print(2 ** (n // 2))
else:
  print(0)

### FIXED CODE ###

import math
N = int(input())


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

A.sort()
ans = 0
flag = True
if N % 2 == 1:
  # 0,2,2,4,4,～みたいに並んでるはず
  if A[0] == 0:
    for i in range(1,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)

else:
  if A[0] != 0:
    for i in range(0,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)
    
    
    
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
if n%2==0:
  for i in range(n):
    if i%2==0:
      ans.append(a[i])
    else:
      ans.insert(0,a[i])
    #print(*ans)
else:
  for i in range(n):
    if i%2==0:
      ans.insert(0,a[i])
    else:
      ans.append(a[i])
    #print(*ans)
print(*ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
if n%2==0:
  front = a[::2]
  back = a[1::2][::-1]
else:
  front = a[1::2]
  back = a[::2][::-1]
ans = back+front
print(*ans)
### BUGGY CODE ###

_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = [[int(p) for p in i.split()] for i in _input[1:n]]

if not edge:
    print(k)
else:
    import collections

    colored  = {}
    edge_map = collections.defaultdict(list)
    for e in edge:
        edge_map[e[0]].append(e[1])
        edge_map[e[1]].append(e[0])

    root = edge[0][0]
    colored[root] = k
    for i, p in enumerate(edge_map[root]):
        colored[p] = k - (i + 1)

    visit = []
    visit.extend(edge_map[root])
    while len(colored) != n:
        current = visit.pop(0)
        diff = 0
        for p in (edge_map[current]):
            if p not in colored:
                colored[p] = k - (diff + 2)
                diff += 1
                visit.insert(0, p)

    total = 1
    for i in colored.values():
        total *= i
        if total > 1000000007:
            total %= 1000000007
    print(total)


### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = tuple([tuple([int(p) for p in i.split()]) for i in _input[1:n]])

factorial = [0] * (k + 1)
inverse = [0] * (k + 1)
MOD = 1000000007

# Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/175024
def mod_pow1(n, k, mod):
    a = 1
    while k:
        if (k & 1) == 1:
            a = (a * n) % mod
        n = (n * n) % mod
        k >>= 1
    return a

# Ref: https://www.smartbowwow.com/2018/10/mod1097.html
def mod_pow2(n, k, mod):
    if k == 0:
        return 1
    if k % 2 == 0:
        a = mod_pow2(n, k // 2, mod)
        return (a * a) % mod
    else:
        return (n * mod_pow2(n, k - 1, mod)) % mod

#mod_pow = mod_pow1
# It's better to use built-in function for speed.
mod_pow = pow

def mod_factorial_inverse(k, mod):
    factorial[0] = 1
    inverse[0] = 1

    # Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
    for i in range(1, k + 1):
        factorial[i] = ((i * factorial[i - 1]) % mod) # factrial[i]
        inverse[i] = mod_pow(factorial[i], mod - 2, mod) # inverse[i]
 
total = 1

if not edge:
    print(k)
else:
    all_edge = tuple([[] for _ in range(n + 1)])
    for e in edge:
        all_edge[e[0]].append(e[1])
        all_edge[e[1]].append(e[0])
    all_edge = [set(v) for v in all_edge]

    if [v for v in all_edge if len(v) >= k]:
        print(0)
    else:
        mod_factorial_inverse(k, MOD)

        root = edge[0]
        total = (factorial[k] * inverse[k - len(all_edge[root[0]]) - 1]) % MOD

        def dfs(current, from_):
            global total
            child = all_edge[current]
            if len(child) - 1 > 0:
                total = (total * factorial[k - 2] * inverse[k - 2 - (len(child) - 1)]) % MOD
            for c in child:
                if c != from_:
                    dfs(c, current)
        for c in all_edge[root[0]]:
            dfs(c, root[0])
        print(total)
### BUGGY CODE ###

N, K  = map(int, input().split())
A_list = list(map(int, input().split()))
#print(A_list)
ans_list = [ 0 for n in range(N)]
tmp = 1
for k in range(K):
    tmp *= A_list[k]
    #print(tmp)
ans_list[K-1] = tmp
#print(ans_list)
for k in range(K, N):
    ans_list[k] = ans_list[k-1]//A_list[k-K] * A_list[k]
#print(ans_list)
for k in range(K, N):
    if ans_list[k] > ans_list[k-1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K  = map(int, input().split())
A_list = list(map(int, input().split()))
'''
#print(A_list)
ans_list = [ 0 for n in range(N)]
tmp = 1
for k in range(K):
    tmp *= A_list[k]
    #print(tmp)
ans_list[K-1] = tmp
#print(ans_list)
for k in range(K, N):
    ans_list[k] = ans_list[k-1]//A_list[k-K] * A_list[k]
'''
#print(ans_list)

for k in range(K, N):
    if A_list[k] > A_list[k-K]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=A[left+i]
    for i in range(n2):
        R[i]=A[mid+i]
    L[n1]=float("inf")
    R[n2]=float("inf")
    i=0
    j=0
    global cnt
    cnt += (right-left)
    for k in range(left,right):
#        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(input().split())
for i in range(n):
    S[i]=int(S[i])
cnt=0
mergeSort(S,0,n)
for i in range(n):
    if i==n-1:
        print(S[i])
    else:
        print(S[i],end=" ")
print(cnt)



### FIXED CODE ###

def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    """
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=A[left+i]
    for i in range(n2):
        R[i]=A[mid+i]
    L[n1]=float("inf")
    R[n2]=float("inf")
    """
    i=0
    j=0
    for k in range(left,right):
        global cnt
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(input().split())
for i in range(n):
    S[i]=int(S[i])
cnt=0
mergeSort(S,0,n)
for i in range(n):
    if i==n-1:
        print(S[i])
    else:
        print(S[i],end=" ")
print(cnt)