Print Numbers in Reverse OrderEasy

Print Numbers in Reverse Order

EasyPractice library · +10 XPrecursionarraysiteration

Given a sequence of N integers, print them in the reverse order they appear in the input. For example, if the input is 1 2 3 4, the output should be 4 3 2 1.

Input

The first line contains a single integer N, representing the number of integers in the sequence. The second line contains N space-separated integers.

Output

Print the N integers in reverse order, separated by spaces, on a single line.

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
10 20 30 40 50
Output
50 40 30 20 10

Prints the numbers in reverse order.

Example 2

Input
3
-1 0 1
Output
1 0 -1

Handles negative numbers and zero correctly.

Hints