Problem:


Score : 300 points

Problem Statement

You are given a sequence of length N: A_1, A_2, ..., A_N.
For each integer i between 1 and N (inclusive), answer the following question:

Find the maximum value among the N-1 elements other than A_i in the sequence.

Constraints

2 \leq N \leq 200000

1 \leq A_i \leq 200000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.

Sample Input 1

3
1
4
3

Sample Output 1

4
3
4

The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.

The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.

The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.

Sample Input 2

2
5
5

Sample Output 2

5
5



Sample input:
3
1
4
3


Sample output:
4
3
4

Submission status: Time Limit Exceeded

Solution code:
import copy

n = int(input())
a = []
a_bak = []
a_sorted = []

for i in range(n):
    a.append(int(input()))

for i in range(n):
    a_bak = copy.copy(a)
    
    a_bak[i] = 0

    a_sorted = sorted(a_bak, reverse=True)

    print(a_sorted[0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  ans = max(a)
  if a[i] == ans:
    temp = ans
    a.remove(ans)
    ans = max(a)
    a.insert(i, temp)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
print(max(a[1:]))
for i in range(1,n):
  ans = max(a[0:i] + a[i+1:n])
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [ int(input()) for i in range(N) ]
ans = [1]*N
for i,x in enumerate(a):
  if i == N-1:
    ans[i]=max(a[:i])
  else:
    ans[i]=max(max(a[:i],a[i+1:]))
    
for i in range(N):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
print(max(a[1:]))
for j in range(1,n-1):
  b=a[:j]+a[j+1:]
  print(max(b))
print(max(a[:n]))

Submission status: Time Limit Exceeded

Solution code:
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    for i in range(N):
        a = A.copy()
        a.pop(i)
        print(max(a))


if __name__ == '__main__':
    p_c()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
alist=[int(input()) for i in range(n)]
for i in range(n):
    if i == 0:
        max_a = 0
    else:
        max_a = max(alist[0:i])
    if i == n-1:
        max_b = alist[-1]
    else:
        max_b = max(alist[i+1:])
    print(max([max_a, max_b]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for _ in range(N):
    A.append(input())

B = A.copy()
B.remove(max(A))
second_max = max(B)
for i in range(N):
    if A[i] == max(A):
        print(second_max)
    else:
        print(max(A))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list) for i in range(N)]
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list) for i in range(list.index(max(list)))]
    list2.append(sorted(list)[-2])
    list3 = [max(list) for j in range(list.index(max(list))+1,N)]
    list2.extend(list3)
    print("\n".join(map(str,list2)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    r = a[i]
    a[i] = 0
    print(max(a))
    a[i] = r

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    print(max(A[:i]+A[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
inp = int(input())
A = []
for a in range(inp):
    A.append(int(input()))
    
m = max(A)

for i, a in enumerate(A):
    if a == m:
        A2 = [v for i2, v in enumerate(A) if i2 != i]
        print(max(A2))
    else:
        print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [input() for i in range(n)]
m = max(nums)
m2 = sorted(nums)[-2]

[print(m) if nums.count(m) >=2 or nums[i] != m else print(m2) for i in range(n)]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [input() for i in range(n)]
m = max(nums)

ans=[m if nums.count(m) >=2 or nums[i] != m else sorted(nums)[-2] for i in range(n)]

for i in range(n):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [input() for i in range(n)]
m = max(nums)

for i in range(n):
  num = nums[i]
  if nums.count(m) >= 2 or num != m:
    print(m)
  else:
    print(sorted(nums)[-2])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    use_list = copy.deepcopy(A)
    del use_list[i]
    use_list = sorted(use_list)
    print(use_list[N-2])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n =	int(input())
nums = [int(input()) for i in range(n)]

num_max = np.max(nums)
next_max = sorted(nums)[-2]


for idx, el in enumerate(nums):
	del nums[idx]
	if num_max == el:
		print(next_max)		
	else:
		print(num_max)
	nums.insert(idx, el)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n =	int(input())
nums = [int(input()) for i in range(n)]

num_max = max(nums)
next_max = num_max

for idx, el in enumerate(nums):
	del nums[idx]
	if num_max == el:
		if next_max == num_max:
			next_max = max(nums)
			print(next_max)
		else:
			print(next_max)
		
	else:
		print(num_max)
	nums.insert(idx, el)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n =	int(input())
nums = [int(input()) for i in range(n)]

num_max = max(nums)

for idx, el in enumerate(nums):
	del nums[idx]
	if num_max == el:
		print(max(nums))
	else:
		print(num_max)
	nums.insert(idx, el)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n =	int(input())
nums = [int(input()) for i in range(n)]

for idx, el in enumerate(nums):
	del nums[idx]
	print(np.max(nums))
	nums.insert(idx, el)

Submission status: Time Limit Exceeded

Solution code:
n =	int(input())
nums = [int(input()) for i in range(n)]

for idx, el in enumerate(nums):
	del nums[idx]
	print(max(nums))
	nums.insert(idx, el)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(int(input()) for i in range(n))

for i in range(n):
  li_copy = li.copy()
  del li_copy[i]
  print(max(li_copy))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    X = A[0:i] + A[i+1:]
    Y = set(X)
    print(max(Y))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    X = A[0:i] + A[i+1:]
    MAX = max(X)
    print(MAX)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list = [int(input()) for i in range(N)]
for i in range(N):
    if list[i] == max(list):
        print(sorted(list)[-2])
    else:
        print(max(list))

Submission status: Time Limit Exceeded

Solution code:
i = int(input())
s = [int(input()) for _ in range(i)]

for n in range(i):
    l = s.pop(n)
    print(max(s))
    s.insert(n,l)

Submission status: Time Limit Exceeded

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

for n in range(i):
    l = s.pop(n)
    print(max(s))
    s.insert(n,l)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
A = [int(input()) for x in range(N)]
ans = max(A)
for i in range(N):
    if A[i] == ans:
        print(max(A[:i] + A[i+1:]))
    else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
A = [int(input()) for x in range(N)]
for i in range(N):
    A[i] = A[i] * -1
    print(max(A))
    A[i] = A[i] * -1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
A = [int(input()) for x in range(N)]
for i in range(N):
    print(max(A[:i] + A[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
a = ["" for _ in range(n)]

for i in range(n):
    a[i] = int(input())


ans = ["" for _ in range(n)]
for i in range(n):
    a_test = a[:]
    del a_test[i]
    ans[i] = max(a_test)


for i in range(n):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]

for idx,i in enumerate(a):
    b = a[:]
    del b[idx]
    print(max(b))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list = [int(input()) for i in range(N)]
a = max(list)
for i in range(N):
    if list[i] == a:
        b = list[i]
        list[i] = 0
        print(max(list))
        list[i] = b
    else:
        print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
for i in range(0, n-1):
    a_i = a[0:i] + a[i+1:n]
    print(max(a_i))
print(max(a[0:n]))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

n = int(input())
alist = deque()
for i in range(n):
    alist.append(int(input()))



anslist = deque()
for _ in range(n):
    ai = alist.popleft()
    anslist.append(max(alist))
    alist.append(ai)

for i in anslist:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = []
b = 0

for i in range(N):
    a.append(int(input()))

for i in range(N):
    b = a[i]
    a[i] = 0
    print(max(a))
    a[i] = b

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
for i in range(len(a)):
  b = a.copy()
  del b[i]
  print((max(b)))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))

num=list()
M=max(l)
for k in range(N):
    if(l[k]==M):
        num=l[:k]+l[k+1:]
        print(max(num))
    else:
        print(M)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))

num=list()
for k in range(N):
    num=l[:k]+l[k+1:]
    print(max(num))

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
	print(max([a for n, a in enumerate(A) if n !=  i]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for _ in range(n)]
for i in range(n):
  print(max(a[:i] + a[(i + 1):]))

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
A=[]
B=[]
for x in range(0,N):
    A.append(int(input()))
    B.append(A[x])
for x in range(0,N):
    A[x]=0
    print(max(A))
    A[x]=B[x]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lis = []

for i in range(n):
	a = int(input())
	lis.append(a)

for i in range(n):
	x = lis.pop(i)
	print(max(lis))
	lis.insert(i,x)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    MAX = max(a)
    for i in range(n):
        ans = MAX
        if a[i] == MAX:
            ans = max(a[:i] + a[i+1:]) if i != n - 1 else max(a[:i])
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N) ]

for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    print(max(tmp))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

a_max = max(A)

for i,a in enumerate(A):
    if a == a_max:
        A[i] -= a
        print(max(A))
        A[i] += a
    else:
        print(a_max)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
for i, num in enumerate(A):
    AA = [x for j, x in enumerate(A) if i != j]
    print(max(AA))

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
a = [int(input()) for i in range(n)]

for a_i in a:
    b = a.copy()
    b.remove(a_i)
    print(max(b))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = int(input())
A = [int(input()) for i in range(N)]
for i, num in enumerate(A):
    AA = A[:]
    AA.pop(i)
    print(max(AA))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

m=max(a)
b=a[:]
b.remove(m)
m2=max(b)

for j in a:
    if j==m and a.count(m)>1:
        print(m)
    elif j==m and a.count(m)==1:
        print(m2)
    else:
        print(m)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
max_A = max(A)
for i in range(N):
    if A[i] == max_A:
        print(max(A[:i]+A[i+1:]))
    else:
        print(max_A)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    for idx in range(n):
        d = max([v for i, v in enumerate(a) if i != idx])
        print(d)


if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
  d = A[i]
  A[i] = 0
  print(max(A))
  A[i] = d

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
A = [int(input())for i in range(0,N)]

for i in range(0,N):
	A_copy = copy.copy(A)
	del A_copy[i]
	list.sort(A_copy,reverse=True)
	print(A_copy[0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = []
for i in range(n):
  li.append(int(input()))

for i in range (n):
  li_2 = li[0:i]+li[i+1:n+1]
  print(max(li_2))

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
a_cp = copy.copy(a)
result = []
for i in range(n):
    a.pop(i)
    result.append(max(a))
    a = copy.copy(a_cp)
for j in result:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
l=[]
for i in range(N):
  val=A.pop(i)
  num=max(A)
  l.append(num)
  A.insert(i,val)
  
for i in range(N):
  print(l[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [0 * x for x in range(N)]
B = [0 * x for x in range(N-1)]

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

M = max(A)
for i in range(N):
  if A[i] == M:
    print(max(A[:i]+A[i+1:]))
  else:
    print (M)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [0 * x for x in range(N)]
B = [0 * x for x in range(N-1)]

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

for i in range(N):
  M = max(A)
  if A[i] == M:
    M = max(A[:i]+A[i+1:])
  print (M)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [0 * x for x in range(N)]
B = [0 * x for x in range(N-1)]

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

for i in range(N):
  print(max(A[:i]+A[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
numbers = [int(input()) for i in range(n)]

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
arr=[]

for i in range(n):
  arr.append(int(input()))
a=max(arr)

for i in range(n):
  if arr[i]!=a:
    print(a)
  else:
    print(max(arr[:i]+arr[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
#134
N=int(input())
a=[int(input()) for i in range(N) ]
a_M=[]
a_M.append( max(a[1:]) )
for i in range(1,N):
    if a[i]<a_M[0]:
        a_M.append(a_M[0])
    else:
        s=a[i]
        a[i]=0
        a_M.append( max(a) )
        a[i]=s   
for x in a_M:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
#134
N=int(input())
a=[int(input()) for i in range(N) ]
a_M=[]
a_M.append( max(a[1:]) )
for i in range(1,N):
    if a[i]<max(a_M):
        a_M.append(max(a_M))
    else:
        s=a[i]
        a[i]=0
        a_M.append( max(a) )
        a[i]=s   
for x in a_M:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
#134
N=int(input())
a=[int(input()) for i in range(N) ]
a_M=[]
for i in range(N):
    s=a[i]
    a[i]=0
    a_M.append( max(a) )
    a[i]=s
for x in a_M:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=[int(input()) for i in range(N) ]
a_M=[]
for i in range(N):
    s=a[i]
    a[i]=0
    a_M.append( max(a) )
    a[i]=s
for x in a_M:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
A.insert(0,0)
A.insert(N+1,0)
ans=max(A)
for i in range(1,N+1):
  if A[i]!=ans:
    print(ans)
  else:
    m1=max(A[:i])
    m2=max(A[i+1:])
    m=max(m1,m2)
    print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
numbers = [int(input()) for i in range(n)]

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

Submission status: Time Limit Exceeded

Solution code:
#n,d=map(int,input().split())
n=int(input())
a=list(int(input())for _ in range(n))
#print("-----------")
for i in range(n):
        tmp=a[i]
        a[i]=0
        print(max(a))
        a[i]=tmp

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) 
t = [int(input()) for i in range(n)] 

for j in t:
  if j != max(t):
  	print(max(t))
  else:
    print(sorted(t)[n-2])

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) 
t = [int(input()) for i in range(n)] 

for j in t:
  if j != sorted(t)[n-1]:
  	print(sorted(t)[n-1])
  else:
    print(sorted(t)[n-2])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a_list=[]
for i in range(N):
    a_list.append(int(input()))
 
for i in range(len(a_list)):
    tmp=[x for j,x in enumerate(a_list) if i!=j]
    print(max(tmp))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list([int(input()) for i in range(N)])
a = max(lst)
for i in range(N):
  if lst[i] != a:
    print(a)
  else:
    copy_lst = lst.copy()
    copy_lst.remove(copy_lst[i])
    print(max(copy_lst))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list([int(input()) for i in range(N)])

for i in range(N):
  copy_lst = lst.copy()
  copy_lst.remove(copy_lst[i])
  print(max(copy_lst))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for i in range(N)]
temp = 0

for i in range(N):
	if A[i] != max(A):
		print(max(A))
	else:
		temp = A[i]
		del A[i]
		print(max(A))
		A.insert(i,temp)
		temp = 0

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for i in range(N)]
temp = 0

for i in range(N):
	temp = A[i]
	del A[i]
	print(max(A))
	A.insert(i,temp)
	temp = 0

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for i in range(N)]
temp = 0

for i in range(N):
	temp = A[i]
	del A[i]
	print(max(A))
	A.insert(i,temp)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
hoge = [int(input()) for i in range(n)]

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    print(np.array(temp).max())

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
hoge = [int(input()) for i in range(n)]

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    temp.sort()
    print(temp[-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
hoge = [int(input()) for i in range(n)]

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    temp = set(temp)
    print(max(temp))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
hoge = [int(input()) for i in range(n)]

max_list = []
for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    max_value = max(temp)
    max_list.append(max_value)
for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
hoge = [int(input()) for i in range(n)]

max_list = []
for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    print(max(temp))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)

for i in range(N):
    if i == A.index(max(A)):
        print(B[-2])
    else:
        print(B[-1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
B = []
while len(A) != N:
    A.append(int(input()))
i = 0
while len(B) < N:
    B.append(A[0:N])
    del B[-1][i]
    print(max(B[-1]))
    i += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, [input() for i in range(n)]))

sum = max(a)
for i in range(n):
    if a[i] == max(a):
        b = a[:]
        b.remove(a[i])
        print(max(b))
    else:
        print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input(''))

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

for i in range(n):
    print(max(xs[0:i] + xs[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = [input() for i in range(N)]

for i in range(0, N):
    f_nums = nums[:i]
    l_nums = nums[i+1:]
    f_nums.extend(l_nums)
    print(max(f_nums))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = [input() for i in range(N)]

max_list = []
for i in range(0, N):
    f_nums = nums[:i]
    l_nums = nums[i+1:]
    f_nums.extend(l_nums)
    _max = max(f_nums)
    max_list.append(_max)

for x in max_list:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = []

for i in range(n):
    a.append(int(input()))

for i in range(n):
    tmp = a[:]
    tmp.pop(i)
    print(max(tmp))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    aaa = a.copy()
    aaa[i] = 0
    print(max(aaa))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [int(input()) for _ in range(n)]
for i in range(n):
  print(max(nums[:i]+nums[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
i=0
j=0
for i in range(n):
  b=-10000
  for j in range(n):
    if j==i:
      continue
    else:
      if b<=a[j]:
        b=a[j]
  print(b)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if i == a.index(A):
            print(b)
        else:
            print(A)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if i == a.index(A):
            print(sorted(a)[-2])
        else:
            print(A)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
for i in range(len(a)):
    if i == a.index(A):
        print(sorted(a)[-2])
    else:
        print(A)

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
a = [int(input()) for i in range(N)]
b = copy.deepcopy(a)
for i in range(len(b)):
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
a = [input() for i in range(N)]
b = copy.deepcopy(a)
for i in range(len(a)):
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
[print((max(a[:_] + a[_ + 1:]))) for _ in range(n)]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    print(max(a[:i] + a[i + 1:]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)

for i in range(N):
    if M == A[i]:
        A[i] *= -1
        print(max(A))
        A[i] *= -1
    else:
        print(M)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    A[i] *= -1
    ans = max(A)
    print(ans)
    A[i] *= -1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
n = []
for i in range(N):
  n.append(input())
  
for i in range(N):
  n1 = n[0:i] + n[i+1:N]
#  n2 = sorted(n1)
#  print(n2[N - 2])
  n2 = max(n1)
  print(n2)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
n = []
for i in range(N):
  n.append(input())
  
for i in range(N):
  n1 = n[0:i] + n[i+1:N]
  n2 = sorted(n1)
  print(n2[N - 2])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]

for i in range(N):
  temp=[s[x] for x in range(i)]+[s[x] for x in range(i+1, N)]
  print(max(temp))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = []

for i in range(n):
  l.append(int(input()))

m = max(l)

if l.count(m) >= 2:
  for i in range(n):
    print(m)
  exit()

for i in range(n):
  tmp = l.pop(i)
  
  if tmp != m:
    print(m)
    l.insert(i,tmp)
    continue
  
  print(max(l))
  l.insert(i,tmp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = []

for i in range(n):
  l.append(int(input()))

m = max(l)
  
for i in range(n):
  tmp = l.pop(i)
  
  if tmp != m:
    print(m)
    l.insert(i,tmp)
    continue
  
  print(max(l))
  l.insert(i,tmp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = []

for i in range(n):
  l.append(int(input()))

for i in range(n):
  tmp = l.pop(i)
  print(max(l))
  l.insert(i,tmp)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
#a, b = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

a = max(s)

for i in range(n) :
    if (s[i] == max(s)) :
        print(sorted(s)[-2])
    else :
        print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(raw_input())
a = [raw_input() for i in xrange(n)]
b = map(int,a)
for i in xrange(n):
    ml = [b[j] for j in xrange(n) if j != i]
    print max(ml)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nums = [int(input()) for i in range(N)]
maxNum = max(nums)
for i in range(N):
    if nums[i] == maxNum:
        print(max(nums[:i] + nums[i+1:]))
    else:
        print(maxNum)

Submission status: Time Limit Exceeded

Solution code:
def ehand(n,a):
    for i in range(n):
        print max(a[:i]+a[(i+1):])
 
if __name__ == '__main__':
    n = int(raw_input())
    a = []
    a = [raw_input() for i in range(n)]
 
    ehand(n,map(int,a))

Submission status: Time Limit Exceeded

Solution code:
def ehand(n,a):
    for i in range(n):
        print max(a[:i]+a[(i+1):])
 
if __name__ == '__main__':
    n = int(raw_input())
    a = []
    a = [raw_input() for i in range(n)]

    ehand(n,map(int,a))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = [ int(input()) for _ in range(n) ]
maxnum = max(num)
for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(max(num[0:i]+num[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = [ int(input()) for _ in range(n) ]
for i in range(n):
    print(max(num[0:i]+num[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

for i in range(N):
    print(max(nums[i+1:]+nums[:i]))

Submission status: Time Limit Exceeded

Solution code:
def ehand(n,a):
    for i in range(n):
        print max(a[:i]+a[(i+1):])

if __name__ == '__main__':
    n = int(raw_input())
    a = []

    for i in range(n):
        a.append(int(raw_input()))

    ehand(n,a)

Submission status: Time Limit Exceeded

Solution code:
import copy
def ehand(n,a):
    for i in range(n):
        b = copy.deepcopy(a)
        del b[i]
        print max(b)

if __name__ == '__main__':
    n = int(raw_input())
    a = []

    for i in range(n):
        a.append(int(raw_input()))

    ehand(n,a)

Submission status: Time Limit Exceeded

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

for i in range(N):	
	B = []
	for j in range(N):
		if i != j:
			B.append(A[j])
	B.sort(reverse = True)
	print(B[0])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
a = np.array([int(input()) for _ in range(n)])
print(max(a[1:]))
for i in range(1, n-1):
    print(max(max(a[:i]), max(a[i+1:])))
print(max(a[:n]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
for i in range(n):
    print(max(a[:i]+a[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
values = [int(input()) for i in range(n)]
result = [max(values[0:x]+values[x+1:]) for x in range(n)]
for val in result:
    print(val)

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp = A_list.pop(i)
        print(max(A_list))
        A_list.insert(i, tmp)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from copy import copy


def main():
    N = int(input())
    A_lsit = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp_list = copy(A_lsit)
        tmp_list.pop(i)
        print(max(tmp_list))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
# input
for i in range(N):
  A.append(int(input()))
  
max_A = max(A)
# output
for i in range(N):
  if A[i] < max_A:
    print(max_A)
  else:
    tmp = A.copy();
    tmp.remove(A[i]);
    print(max(tmp))

Submission status: Time Limit Exceeded

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

# output
for i in range(N):
  tmp = A.copy();
  tmp.remove(A[i]);
  print(max(tmp))

Submission status: Time Limit Exceeded

Solution code:
import copy

n = int(input().split()[0])
a_list = []

for _ in range(n):
    a_list.append(int(input().split()[0]))

max_str = ''

for i, a in enumerate(a_list):
    kouho_list = copy.copy(a_list)
    kouho_list.pop(i)
    max_str += '{}\n'.format(max(kouho_list))

print(max_str[:-1])