Queue ReverserEasy

Queue Reverser

EasyPractice library · +10 XPqueuestacksimulation

Given a sequence of N integers, insert them into a queue. Then, reverse the order of elements in the queue. Finally, print the elements of the queue from front to back.

Input

The first line contains an integer N (1 <= N <= 1000). The second line contains N space-separated integers.

Output

Print N space-separated integers, the elements of the queue in reversed order.

Constraints

1 <= N <= 1000. Each integer is between -1000 and 1000.

Time limit 1 s (native code; slower languages get more)Memory 256 MB12 hidden tests

Example 1

Input
5
1 2 3 4 5
Output
5 4 3 2 1

A simple case with 5 elements.

Example 2

Input
3
10 -5 0
Output
0 -5 10

A case with a mix of positive, negative, and zero values.

Hints