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

~/algor $ cat problems/massiv-nolga-tenglashtirish

Zeroing between min and max

Easy 1000 ms 128 MB 32%
Share

A positive integer $n$ and an array of $n$ distinct integers ($n \ge 3$) are given. Replace with $0$ all elements located between the smallest and the largest elements (the smallest and the largest elements themselves do not change) and print the array.

Zeroing the range between the minimum and the maximum

Input

The first line contains a positive integer $n$. The second line contains $n$ distinct integers separated by spaces.

Output

One line with $n$ integers separated by spaces.

Note

$3 \le n \le 1000$
$-10^{9} \le a_{i} \le 10^{9}$

Examples

Input #1
7
12 3 8 14 5 20 7
Output #1
12 3 0 0 0 20 7
Input #2
4
10 1 5 2
Output #2
10 1 5 2

Sign in to submit a solution

Signing up is free and takes a minute.