#C14157. Consecutive Duplication

    ID: 43775 Type: Default 1000ms 256MiB

Consecutive Duplication

Consecutive Duplication

Given a list of integers, duplicate each element consecutively. In other words, for every integer in the list, output it twice in the same order.

The mathematical formulation is: if the input list is \(a = [a_1,a_2,\dots,a_n]\), then the output list should be \(b = [a_1,a_1,a_2,a_2,\dots,a_n,a_n]\).

For example:

  • If \(a = [1, 2, 3]\), then \(b = [1, 1, 2, 2, 3, 3]\).
  • If \(a = [1, 1, 2, 3, 3, 3]\), then \(b = [1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3]\).

inputFormat

The input is given from standard input (stdin) and follows the format below:

  1. The first line contains a single integer \(n\) representing the number of elements in the list.
  2. The second line contains \(n\) space-separated integers.

If \(n = 0\), then the second line may be omitted.

outputFormat

Output the transformed list to standard output (stdout) as a sequence of space-separated integers. If the resulting list is empty, output an empty string.

## sample
0