N = raw_input()
counter = 0
num_array = []
while counter < int(N):
  num_array.append(int(raw_input()))
  counter += 1
counter = 0  
while counter < int(N):
  idx_0 = (counter + (int(N) - 1)) % int(N)
  idx_1 = (counter + 1) % int(N)
  print max(num_array[idx_0], num_array[idx_1])
  counter += 1 
 