N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
i=l.index(max(l))
if i==0:
  l1=l[1:]
  print(max(l1),max(l)*(N-1),sep='\n')
elif i==N:
  l1=l[:N]
  print(max(l)*(N-1),max(l1),sep='\n')
else:
  l1=l[:i]+l[i+1:]
  print(max(l)*(i),max(l1),max(l)*(N-i-1),sep=('\n'))