This page is still under construction.

Parts of this page are still being built. What you see may change.

Lightning Conductor

Time limit1sMemory limit128 MB

Summary
For each building i, find the smallest integer p such that h_i + p - sqrt(|i-j|) >= h_j for every building j.
Level

Hard8 of 10

Topics
Divide and conquer, Dynamic programming, Math
Solved
No attempts yet

Problem

Worsening climate change has forced the city of Byteburg to build one large lightning conductor that protects every building in the city. The buildings stand in a single row along one street and are numbered from 11 to nn.

The heights of the buildings and of the lightning conductor are non-negative integers. The budget allows only a single lightning conductor to be built, and, as you would expect, the taller it is, the more it costs.

A lightning conductor of height pp placed on the roof of building ii (whose height is hih_i) protects building jj (whose height is hjh_j) exactly when

hj≤hi+p−∣i−j∣h_j \le h_i + p - \sqrt{|i - j|}

where ∣i−j∣|i - j| is the absolute difference of the two building numbers.

For every building ii, determine the smallest height of a lightning conductor that, placed on top of building ii, would protect all of the buildings.

Input

The first line contains a single integer nn (1≤n≤500,0001 \le n \le 500{,}000), the number of buildings.

Each of the next nn lines contains a single integer hih_i (0≤hi≤1,000,0000 \le h_i \le 1{,}000{,}000), the height of the ii-th building.

Output

Print exactly nn lines. The ii-th line must contain one non-negative integer pip_i: the minimum height of a lightning conductor placed on the ii-th building that protects every building.

Examples1

  1. Example 1

    Input
    6
    5
    3
    2
    4
    2
    4
    
    Expected output
    2
    3
    5
    3
    5
    4