F. Factions vs The Hegemon
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
5
3 1 4 9 1
Output
4 9
3 8
1 3
2 6
5 12
Input
6
12 4 12 1 1 7
Output
1 12
3 12
5 1
4 7
6 10
2 24