codeforces#P1237D. Balanced Playlist

    ID: 30560 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>binary searchdata structuresimplementation*2000

Balanced Playlist

Description

Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of nn tracks numbered from 11 to nn. The playlist is automatic and cyclic: whenever track ii finishes playing, track i+1i+1 starts playing automatically; after track nn goes track 11.

For each track ii, you have estimated its coolness aia_i. The higher aia_i is, the cooler track ii is.

Every morning, you choose a track. The playlist then starts playing from this track in its usual cyclic fashion. At any moment, you remember the maximum coolness xx of already played tracks. Once you hear that a track with coolness strictly less than x2\frac{x}{2} (no rounding) starts playing, you turn off the music immediately to keep yourself in a good mood.

For each track ii, find out how many tracks you will listen to before turning off the music if you start your morning with track ii, or determine that you will never turn the music off. Note that if you listen to the same track several times, every time must be counted.

The first line contains a single integer nn (2n1052 \le n \le 10^5), denoting the number of tracks in the playlist.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9), denoting coolnesses of the tracks.

Output nn integers c1,c2,,cnc_1, c_2, \ldots, c_n, where cic_i is either the number of tracks you will listen to if you start listening from track ii or 1-1 if you will be listening to music indefinitely.

Input

The first line contains a single integer nn (2n1052 \le n \le 10^5), denoting the number of tracks in the playlist.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9), denoting coolnesses of the tracks.

Output

Output nn integers c1,c2,,cnc_1, c_2, \ldots, c_n, where cic_i is either the number of tracks you will listen to if you start listening from track ii or 1-1 if you will be listening to music indefinitely.

Samples

输入数据 1

4
11 5 2 7

输出数据 1

1 1 3 2

输入数据 2

4
3 2 5 3

输出数据 2

5 4 3 6

输入数据 3

3
4 3 6

输出数据 3

-1 -1 -1

Note

In the first example, here is what will happen if you start with...

  • track 11: listen to track 11, stop as a2<a12a_2 < \frac{a_1}{2}.
  • track 22: listen to track 22, stop as a3<a22a_3 < \frac{a_2}{2}.
  • track 33: listen to track 33, listen to track 44, listen to track 11, stop as a2<max(a3,a4,a1)2a_2 < \frac{\max(a_3, a_4, a_1)}{2}.
  • track 44: listen to track 44, listen to track 11, stop as a2<max(a4,a1)2a_2 < \frac{\max(a_4, a_1)}{2}.

In the second example, if you start with track 44, you will listen to track 44, listen to track 11, listen to track 22, listen to track 33, listen to track 44 again, listen to track 11 again, and stop as a2<max(a4,a1,a2,a3,a4,a1)2a_2 < \frac{max(a_4, a_1, a_2, a_3, a_4, a_1)}{2}. Note that both track 11 and track 44 are counted twice towards the result.