#K2911. Running Maximum

    ID: 24842 Type: Default 1000ms 256MiB

Running Maximum

Running Maximum

You are given an array of integers. Your task is to compute the running maximum of the array. Formally, for an array \(a = [a_0, a_1, \dots, a_{n-1}]\), the running maximum array \(r = [r_0, r_1, \dots, r_{n-1}]\) is defined as:

[ r_i = \max_{0 \le j \le i} a_j, \quad \text{for } 0 \le i < n. ]

For example, if the input array is [1, 3, 2, 10, 5], then the running maximum array is [1, 3, 3, 10, 10].

You need to read the input from the standard input (stdin) and write the computed running maximum to the standard output (stdout). The output should be printed as a sequence of numbers separated by spaces.

inputFormat

The first line of input contains a single integer \(n\) indicating the number of elements in the array. The second line contains \(n\) space-separated integers which represent the array \(a_0, a_1, \dots, a_{n-1}\).

outputFormat

Output a single line containing \(n\) space-separated integers where the \(i\)-th integer represents the running maximum \(r_i\) of the array up to index \(i\).

## sample
5
1 3 2 10 5
1 3 3 10 10