#K58242. Left Inversion Transformation

    ID: 30599 Type: Default 1000ms 256MiB

Left Inversion Transformation

Left Inversion Transformation

You are given an integer ( n ) and an array ( a ) of ( n ) integers. Your task is to perform the Left Inversion Transformation on the array ( a ) and output the resulting array ( b ). The transformation works as follows: for each index ( i ) (0-indexed), if ( i ) is even, insert ( a[i] ) at the beginning of ( b ); if ( i ) is odd, append ( a[i] ) to the end of ( b ).

For example, if ( n = 5 ) and ( a = [1, 2, 3, 4, 5] ), the processing steps are:
- For ( i = 0 ) (even): ( b = [1] )
- For ( i = 1 ) (odd): ( b = [1, 2] )
- For ( i = 2 ) (even): insert 3 at beginning, ( b = [3, 1, 2] )
- For ( i = 3 ) (odd): ( b = [3, 1, 2, 4] )
- For ( i = 4 ) (even): insert 5 at beginning, ( b = [5, 3, 1, 2, 4] )

inputFormat

The input consists of two lines. The first line contains an integer ( n ) representing the number of elements in the array. The second line contains ( n ) space-separated integers, which are the elements of the array ( a ).

outputFormat

Output the transformed array ( b ) as a sequence of integers separated by a single space.## sample

5
1 2 3 4 5
5 3 1 2 4