A gate scanner records boarding-pass IDs as a singly linked chain: the first node is the earliest scan, and each node links to the next scan. You must reverse the whole chain so the last scan becomes the first, and print the reversed sequence of values.
Input format
Line 1: an integer n, the number of nodes in the chain.
Line 2: n space-separated integers, the node values from head to tail (this line is empty when n is 0).
Output format
Line 1: the number of nodes in the reversed chain. Line 2: the reversed values, space-separated (an empty line when the chain is empty).
Constraints
- 0 <= n <= 100000
- -1000000000 <= each value <= 1000000000