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

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = [0] + H
dp = [0] * (N + 1)
dp[1] = 0
dp[2] = abs(H[2] - H[1])

for i in range(3, N+1):
    dp[i] = 1000000000
    for j in range(1, K + 1):
        if i - j >= 1:
            dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]))
print(dp[N])

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = [0] + H
dp = [0] * (N + 1)
dp[1] = 0
dp[2] = abs(H[2] - H[1])

for i in range(3, N+1):
    dp[i] = dp[i - 1] + abs(H[i] - H[i - 1])
    for j in range(1, K + 1):
        if i - j <= 0:
            break
        dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]))
print(dp[N])
### BUGGY CODE ###

import numpy as np
S = input()
n = len(S)

L = [(10**(n - i - 1) * int(s)) % 2019  for  i, s in enumerate(S)]

count = 0
for i in range(n):
    count += (np.cumsum(L[i:]) % 2019 == 0).sum()

print(count)

### FIXED CODE ###

a = input()
n = len(a)

s = 0 # s[0]の余り
c = [0] * 2019 # c[i] = 余り i の個数
c[s] += 1
d = 1 # 10**i mod 2019

for i in range(n):
    s = (s + d * int(a[n-i-1])) % 2019 # s[i+1]の余り
    d = d * 10 % 2019 #10**(i+1) mod 2019
    c[s] += 1

print(int(sum([i*(i-1)/2 for i in c])))
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, input().split())
fr = [0]*n
uf_fr = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf_fr.union(a-1, b-1)
    fr[a-1] += 1
    fr[b-1] += 1

for i in range(k):
    c, d = map(int, input().split())
    if uf_fr.find(c-1) == uf_fr.find(d-1):
        fr[c-1] += 1
        fr[d-1] += 1

ans_list = []
for i in range(n):
    ans_list.append(len(uf_fr.members(i)) - fr[i] - 1)
print(*ans_list)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, input().split())
fr = [0]*n
uf_fr = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf_fr.union(a-1, b-1)
    fr[a-1] += 1
    fr[b-1] += 1

for i in range(k):
    c, d = map(int, input().split())
    if uf_fr.find(c-1) == uf_fr.find(d-1):
        fr[c-1] += 1
        fr[d-1] += 1

ans_list = []
for i in range(n):
    ans_list.append(uf_fr.size(i) - fr[i] - 1)
print(*ans_list)
### BUGGY CODE ###

from itertools import combinations
n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
ans = 0
s1 = set(s)
for i in s1:
    ans += len(list(combinations([i for i in range(s.count(i))], 2)))
print(ans)


### FIXED CODE ###

import collections
 
N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush

N = int(input())
INF = float("inf")
d = [INF for n in range(N)]
d[0] = 0
adj = [[] for _ in range(N)]

searched = [False for _ in range(N)]
searched[0] = True

for n in range(N):
    inp = tuple(map(int, input().split()))
    assert n == inp[0]
    for i in range(inp[1]):
        adj[n] = list(zip(inp[2::2], inp[3::2]))

heap = [[0, 0]]

while len(heap):
    pcost, p = heappop(heap)
    searched[p] = True
    
    if d[p] < pcost:
        continue
    
    for v, c in adj[p]:
        if not searched[v]:
            new_cost = pcost + c
            if new_cost < d[v]:
                d[v] = new_cost
                heappush(heap, [new_cost, v])

for n in range(N):
    print("{} {}".format(n, d[n]))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
INF = float("inf")
N = int(input())
G = []
for _ in range(N):
    I = inpl()
    G.append(zip(*[I[3::2], I[2::2]]))

def dijkstra(G):
    C = [INF]*(N)
    C[0] = 0
    visited = [False] * (N)
    Q = [[0, 0]]

    while Q:
        c, u = heappop(Q)
        if C[u] < c:
            continue
        visited[u] = True
        for d, v in G[u]:
            if visited[v]:
                continue
            e = c + d
            if e < C[v]:
                C[v] = e
                heappush(Q, [e, v])
    return C

for i, c in enumerate(dijkstra(G)):
    print(i, c)
### BUGGY CODE ###

H,W = map(int,input().split())
G = []

for n in range(H):
  G = G + [input()]
  
L = [[0 for w in range(W)] for h in range(H)]
R = [[0 for w in range(W)] for h in range(H)]
U = [[0 for w in range(W)] for h in range(H)]
D = [[0 for w in range(W)] for h in range(H)]

for i in range(H):
  for j in range(1,W):
    if G[i][j]=='#' or G[i][j-1]=='#':
      L[i][j] = 0
    else:
      L[i][j] = L[i][j-1]+1
        
    if G[i][W-1-j]=='#' or G[i][W-j]=='#':
      R[i][W-1-j] = 0
    else:
      R[i][W-1-j] = R[i][W-j]+1
  
for i in range(1,H):
  for j in range(W):
    if G[i][j]=='#' or G[i-1][j]=='#':
      U[i][j] = 0
    else:
      U[i][j] = U[i-1][j]+1
        
    if G[H-1-i][j]=='#' or G[H-i][j]=='#':
      D[H-1-i][j] = 0
    else:
      D[H-1-i][j] = D[H-i][j]+1

v = [0]*H
for i in range(H):
  v_ = [0]*W
  for j in range(W):
    if G[i][j]=='.':
      v_[j] = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
  v[i] = max(v_)
print(max(v))

### FIXED CODE ###

H,W = map(int,input().split())
G = []

for n in range(H):
  G = G + [input()]
  
L = [[0 for w in range(W)] for h in range(H)]
R = [[0 for w in range(W)] for h in range(H)]
U = [[0 for w in range(W)] for h in range(H)]
D = [[0 for w in range(W)] for h in range(H)]

for i in range(H):
  for j in range(1,W):
    if G[i][j]=='#' or G[i][j-1]=='#':
      L[i][j] = 0
    else:
      L[i][j] = L[i][j-1]+1
        
    if G[i][W-1-j]=='#' or G[i][W-j]=='#':
      R[i][W-1-j] = 0
    else:
      R[i][W-1-j] = R[i][W-j]+1
  
for i in range(1,H):
  for j in range(W):
    if G[i][j]=='#' or G[i-1][j]=='#':
      U[i][j] = 0
    else:
      U[i][j] = U[i-1][j]+1
        
    if G[H-1-i][j]=='#' or G[H-i][j]=='#':
      D[H-1-i][j] = 0
    else:
      D[H-1-i][j] = D[H-i][j]+1

v = [0]*H
for i in range(H):
  v_ = [0]*W
  for j in range(W):
    if G[i][j]=='.':
      v_[j] = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
  v[i] = max(v_)
print(max(v))
### BUGGY CODE ###

#d
def main():
    n=int(input())
    a=[0]*(n-1)
    b=[0]*(n-1)
    for i in range(n-1):
        a[i],b[i] = map(int,input().split())
    import collections
    k=collections.Counter(a+b).most_common()[0][1]
    color_list=list(range(k))
    
    tree=[[] for _ in range(n)]
    for i in range(n-1):
        tree[a[i]-1].append(b[i])
        tree[b[i]-1].append(a[i])
        
    used_colors=[[] for _ in range(n)]
    ans=dict()
    q = [(1,0)]
    #while q:
    for _ in range(n):
        x,parent = q.pop()
        if parent!=0:
            current_color=list(set(color_list)-set(used_colors[parent-1]))[0]
            
            used_colors[parent-1].append(current_color)
            used_colors[x-1].append(current_color)
        
            ans[str(parent)+"_"+str(x)]=current_color
        for y in tree[x-1]:
            if y == parent:
                continue
            q.append((y,x))   
    print(k)
    for i in range(n-1):
        s=str(a[i])+"_"+str(b[i])
        print(ans[s]+1)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n=int(input())
    a=[0]*(n-1)
    b=[0]*(n-1)
    for i in range(n-1):
        a[i],b[i] = map(int,input().split())
    import collections
    k=collections.Counter(a+b).most_common()[0][1]
    color_list=list(range(k))
    
    tree=[[] for _ in range(n)]
    for i in range(n-1):
        tree[a[i]-1].append(b[i])
        
    q = collections.deque([(0,1,0)])#親、子、色
    ans=dict()
    while q:
        parent,togo,old_color = q.popleft()
    #    print(parent,togo,old_color)
        col=1
        for togotogo in tree[togo-1]:
    #        print(togotogo)
            if togotogo == parent:
                continue
            if col == old_color:
                col+=1
            q.append((togo,togotogo,col))
            ans["_".join(map(str,(togo,togotogo)))]=col
            col+=1
        
    print(k)
    for i in range(n-1):
        s=str(a[i])+"_"+str(b[i])
        print(ans[s])
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

INF = float('inf')

class SegmentTree:
    def __init__(self, size):
        self._size = (1 << size.bit_length())
        self._data = [INF] * (self._size * 2)

    def update(self, index, value):
        index += self._size - 1
        self._data[index] = value
        while index > 0:
            index = (index - 1) // 2
            self._data[index] = min(self._data[index * 2 + 1], self._data[index * 2 + 2])

    def __query(self, qLeft, qRight, node, left, right):
        if right <= qLeft or qRight <= left:
            return INF
        if qLeft <= left and right <= qRight:
            return self._data[node]

        leftVal = self.__query(qLeft, qRight, node * 2 + 1, left, (left + right) // 2)
        rightVal = self.__query(qLeft, qRight, node * 2 + 2, (left + right) // 2, right)
        return min(leftVal, rightVal)

    def query(self, left, right):
        return self.__query(left, right, 0, 0, self._size)

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

minTree = SegmentTree(N)
maxTree = SegmentTree(N)

for i, p in enumerate(P):
    minTree.update(i, p)
    maxTree.update(i, -p)

ans = 1
hasSame = False
seq = 1
for i in range(1, K):
    if P[i - 1] < P[i]:
        seq += 1
    else:
        seq = 1
if seq >= K:
    hasSame = True

for left in range(N - K):
    right = left + K

    if P[right - 1] < P[right]:
        seq += 1
    else:
        seq = 1

    if minTree.query(left, right) == P[left] and maxTree.query(left + 1, right + 1) == -P[right]:
        continue
    else:
        if seq >= K:
            if hasSame:
                continue
            else:
                hasSame = True
        ans += 1

print(ans)

### FIXED CODE ###

from collections import deque

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

maxQ = deque([])
minQ = deque([])

for i in range(K):
    while maxQ:
        if P[maxQ[-1]] <= P[i]:
            maxQ.pop()
        else:
            break
    maxQ.append(i)
    if maxQ[0] == i - K:
        maxQ.popleft()

    while minQ:
        if P[minQ[-1]] >= P[i]:
            minQ.pop()
        else:
            break
    minQ.append(i)
    if minQ[0] == i - K:
        minQ.popleft()

ans = 1
hasSame = False
seq = 1
for i in range(1, K):
    if P[i - 1] < P[i]:
        seq += 1
    else:
        seq = 1
if seq >= K:
    hasSame = True

for left in range(N - K):
    right = left + K

    if P[right - 1] < P[right]:
        seq += 1
    else:
        seq = 1

    while maxQ:
        if P[maxQ[-1]] <= P[right]:
            maxQ.pop()
        else:
            break
    maxQ.append(right)
    if maxQ[0] == right - K:
        maxQ.popleft()

    if left == minQ[0] and right == maxQ[0]:
        pass
    else:
        if seq < K:
            ans += 1
        else:
            if not hasSame:
                hasSame = True
                ans += 1

    while minQ:
        if P[minQ[-1]] >= P[right]:
            minQ.pop()
        else:
            break
    minQ.append(right)
    if minQ[0] == right - K:
        minQ.popleft()

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

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

ans_list =[]

for i in range(1, min(a, b)+1):
  
  if a%i==0 and b%i==0:
    ans_list.append(i)
    a //= i
    b //= i

print(len(ans_list))

### FIXED CODE ###

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

print(len(set(factorize(a))&set(factorize(b)))+1)
### BUGGY CODE ###

N,X=map(int,input().split())
x=list(map(int,input().split()))
w=[x[-1]]
for y in x[N-2::-1]:w+=[w[-1]+y]
print(min(sum(max(5,2*j+1)*(w[min(N,k*j)-1]-(0 if j==1 else w[k*j-k-1]))for j in range(1,1-(-N//k)))+(N+k)*X for k in range(1,N+1)))

### FIXED CODE ###

N,X=map(int,input().split())
w=[0]
for i in map(int,input().split()):w+=[w[-1]+i]
print(min(5*w[N]+k*X+sum(2*w[j]for j in range(N-k*2,0,-k))for k in range(1,N+1))+N*X)
### BUGGY CODE ###

def solution():
    n, m = map(int, input().split())
    a = [int(aa) for aa in input().split()]
    a.sort(reverse=True)
    for i in range(m):
        a[0] = a[0] // 2
        a.sort(reverse=True)
    print(sum(a))

solution()


### FIXED CODE ###

import heapq as hp
def solution():
    n, m = map(int, input().split())
    a = [int(aa) * -1 for aa in input().split()]
    hp.heapify(a)
    for i in range(m):
        hp.heappush(a, (hp.heappop(a)*-1 // 2) * -1)
    print(abs(sum(a)))

solution()
### BUGGY CODE ###

def main():
    import fractions
    import sys
    input = sys.stdin.readline
    n=int(input())
    a = [int(x) for x in input().split()]
    ans = a[0]

    mmm=10**9+7
    for i in a[1:]:
        ans = (ans *i )// fractions.gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from fractions import gcd
    import sys
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = 1

    mmm=10**9+7
    for i in a:
        ans = ans *i // gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

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

# abc152
n = int(input())
lists = list(input().split())
number_list = list(map(int,lists))
ans = 0
for i in range(n):
    ans += 1
    for j in range(i):
        if number_list[j] <= number_list[i]:
            ans -= 1
            break
                
print(ans)

### FIXED CODE ###

# abc152

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

std = lists[0]
ans = 1

for i in range(1,n):
    if lists[i] < std:
        ans += 1
        std = lists[i]
        
print(ans)
### BUGGY CODE ###

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
s = set(a)
if len(s) < k:
    print 0
    exit()
d = sorted([(i, a.count(i)) for i in s], key = lambda x: x[1])
cnt = 0
for i in d[:len(s) - k]:
    cnt += i[1]
print cnt


### FIXED CODE ###

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
s = set(a)
if len(s) < k:
    print 0
    exit()
d = dict()
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
cnt = 0
for i in sorted(d.values())[:len(s) - k]:
    cnt += i
print cnt
### BUGGY CODE ###

n = input()
al = [int(x) for x in input().split()]
aset = set(al)

# {number: count}
counts_d = {i: sum(a == i for a in al) for i in aset}

vset = set(counts_d.values())
# Count of count
v_counts = {v: sum(v == i for i in counts_d.values()) for v in vset}

whole_patterns = sum(
    (int(k * (k - 1) / 2)) * v for k, v in v_counts.items() if k > 1
)

[print(whole_patterns - counts_d[a] + 1) for a in al]

# C013_scrambled まで通り，次からTLE


### FIXED CODE ###

import collections

n = input()
al = tuple(x for x in input().split())
aset = set(al)

# {number: count}
ccc = collections.Counter
counts_d = ccc(al)

# Count of count
v_counts = ccc(v for v in counts_d.values())

whole_patterns = sum(
    (int(k * (k - 1) / 2)) * v for k, v in v_counts.items() if k > 1
)

[print(whole_patterns - counts_d[a] + 1) for a in al]
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
count = 0
b = 0
A.sort()

for i in range(A[1]-1):

    count = 0

    for j in range(N):
        if A[j] % (A[1] - i) !=0:
            count += 1
        
    if count == 1:
        b = A[1] - i
        break
    else:
        continue

if b == 0:
    print(A[0])
else :
    print(b)

### FIXED CODE ###

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

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

res = [0] * N
l = [0] * (N+1)
r = [0] * (N+1)

for i in range(N):
    l[i+1] = gcd(l[i],A[i])

for i in range(N,0,-1):
    r[i-1] = gcd(r[i],A[i-1])

for i in range(N):
    res[i] = gcd(l[i],r[i+1])

print(max(res))
### BUGGY CODE ###

K, S = map(int, input().split())
ct = 0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      ct += (1 if X + Y + Z == S else 0)
print(ct)

### FIXED CODE ###

K, S = map(int, input().split())
ct = 0
for X in range(K+1):
  for Y in range(K+1):
    if S - (X + Y) >= 0 and S - (X + Y) <= K :
        ct += 1 

print(ct)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
A.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            continue
        ans += (A[i] * (sum(A[j:N]) % MOD)) %MOD
        break

print(ans % MOD)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
A.sort()
ans = 0
sumA = sum(A)
for i in range(N):
    sumA -= A[i]
    for j in range(i+1,N):
        if A[i] > A[j]:
            continue
        ans += (A[i] * (sumA % MOD)) %MOD
        break

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

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = [[[0 for _ in range(z)] for __ in range(y)] for ___ in range(x)]

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and abc[n+1][m][l]==0:
        abc[n+1][m][l]=1
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and abc[n][m+1][l]==0:
        abc[n][m+1][l]=1
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and abc[n][m][l+1]==0:
        abc[n][m][l+1]=1
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)

### FIXED CODE ###

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
### BUGGY CODE ###

a = [0 for i in range(10 ** 9)]

### FIXED CODE ###

a,b = map(int, input().split())
if a >= 13:
  print(b)
elif 6 <= a <= 12:
  print(b//2)
else:
  print(0)
### BUGGY CODE ###

def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    while r - l > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = ((c - N*(N-1)//4) * 2) ** 0.5
        else:
            r = m
            rc = ((N*(N-1)//4 - c) * 2 + 1) ** 0.5
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

### FIXED CODE ###

def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    f = 1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l+r) / 2 if f else (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
        f ^= 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))
### BUGGY CODE ###

N = int(input())
ss = [''.join(sorted(input())) for _ in range(N)]
ssset = set(ss)

ans = 0
for s in ssset:
    n = ss.count(s)
    if n > 1:
        ans += n * (n - 1) // 2

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
ss = [''.join(sorted(input())) for _ in range(N)]

sscounts = Counter(ss)

ans = 0
for s, n in sscounts.items():
    if n > 1:
        ans += n * (n - 1) // 2

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

import numpy as np

N = int(input())
A = []
for i in range(N):
    A.append(input())

A = np.array(A)

for i in range(N):
    print(max(np.delete(A, [i], axis=0)))
    

### FIXED CODE ###

def main():
    a = int(input())
    lists= [int(input()) for _ in range(a)]
 
    temp = lists.copy()
    first = max(temp)
    temp.remove(first)
    second = max(temp)
 
    for i in range(a):
        if lists[i] == first:
            print(second)
        else:
             print(first)
 
if __name__ == '__main__' :
    main()