Reverse ArrayEasy

Reverse Array

EasyPractice library · +10 XPrecursionarraysbacktracking

Given an array of N integers, print the elements in reverse order. The elements should be separated by spaces.

Input

The first line contains an integer N, the number of elements in the array. The second line contains N space-separated integers.

Output

Print the N integers in reverse order, separated by spaces.

Constraints

1 <= N <= 1000 -10^9 <= elements <= 10^9

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

Example 1

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

Reverses the array [1, 2, 3, 4, 5] to [5, 4, 3, 2, 1].

Example 2

Input
3
10 20 30
Output
30 20 10

Reverses the array [10, 20, 30] to [30, 20, 10].

Hints