eolymp
bolt
Try our new interface for solving problems
Problems

The last the largest

The last the largest

Time limit 1 second
Memory limit 128 MiB

Given array of n integers. Find the largest element of the array that occurs the last and swap it with the last element in the array without changing the order of other elements.

Input data

First line contains positive integer n. Next line contains n integers. All numbers do not exceed 100 by absolute value.

Output data

Print the elements of updated array.

Examples

Input example #1
7
6 -3 7 -4 7 4 -5
Output example #1
6 -3 7 -4 -5 4 7
Author Matviychuk Sergiy Volodymyrovych
Source "ABC programming"