Candy Sales

For each day j, print the minimum over all i at most j of w_i + (j - i).

Medium5ArrayPrefix sumImplementationInterviewNo attempts yetTime limit6sMemory limit512 MB

Problem

Cathy's favourite candy brand is releasing n new flavours, one new flavour on each of the next n days. A pack of flavour ii, the flavour released on day ii, costs wiw_i dollars on its release day. To get customers to try the new flavours, the price of a flavour goes up by one dollar on each day after its release. On day jij \ge i, a pack of the flavour released on day ii costs

wi+(ji)w_i + (j - i)

dollars.

Cathy buys exactly one pack of candy on each of the next n days and wants to get the most candy for her money. Compute the price of the cheapest pack of candy available on each of the next n days. Every flavour has an unlimited number of packs and is on sale on its release day and on all later days.

Input

The input consists of two lines. The first line contains an integer nn (1n2000001 \le n \le 200\,000), the number of flavours. The second line contains nn integers w1,w2,,wnw_1, w_2, \dots, w_n (1wi1000001 \le w_i \le 100\,000), where wiw_i is the release-day price of flavour ii in dollars.

Output

Print n integers on one line, separated by single spaces. The i-th integer is the price of the cheapest pack of candy that Cathy can buy on day i.