Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/minmax-28-prefiks-minimumlari

Minimum at every step

Easy 1000 ms 128 MB 33%
Share

A positive integer $N$ and $N$ integers are given. For every $k$ ($1 \le k \le N$), find the smallest of the first $k$ elements $A_{1}, A_{2}, \ldots, A_{k}$.

At every step the smallest number met so far is written down

Input

The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.

Output

One line with $N$ integers separated by spaces: the smallest numbers found for $k = 1, 2, \ldots, N$.

Note

$1 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$

Examples

Input #1
6
5 7 3 4 1 2
Output #1
5 5 3 3 1 1
Input #2
1
-8
Output #2
-8

Sign in to submit a solution

Signing up is free and takes a minute.