Exchange Nodes


Submit solution

Points: 10 (partial)
Time limit: 8.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Python

Exchange Nodes

Given a circular linked list, Your task is to exchange first and last node.The task should be done with only one extra node, you can not declare more than one extra node.

Input Format

First line contain N, the number of nodes in the list. Second line contain line contain N space separated integers denoting value at nodes in circular linked list.

Output Format

Output final list after exchanging.

Sample TestCase 1

Input

6

17 22 13 14 15 16

Output

16 22 13 14 15 17


Comments

There are no comments at the moment.