Under construction

Still being built. Things may change

What if a car takes the side of its owner, Kim Pyojun?

Interview

Time limit1sMemory limit512 MB

Summary
For each window length k from 1 to N, find the starting index of the length-k subarray with the largest standard deviation, breaking ties by the smallest index.
Level

Easy3 of 10

Topics
Array, Prefix sum, Brute force, Math
Solved
No attempts yet

Problem

A sequence A1,A2,…,ANA_1, A_2, \dots, A_N of length NN is given. Write a program that does the following for k=1,2,…,Nk = 1, 2, \dots, N in order.

  • Let σi\sigma_i be the standard deviation of the length-kk interval Ai,Ai+1,…,Ai+k−1A_i, A_{i+1}, \dots, A_{i+k-1} starting at AiA_i. Print the ii for which σi\sigma_i is largest. If there are several such ii, print the smallest one.

For example, if the sequence is 1,3,6,10,151, 3, 6, 10, 15 and k=2k = 2, the output is 44, because among intervals of length 2 the one with the largest standard deviation is 10,1510, 15.

Input

The first line gives the length NN of the sequence. (1≤N≤1,0001 \le N \le 1{,}000)

The second line gives the sequence A1,A2,…,ANA_1, A_2, \dots, A_N. (1≤Ai≤1,000,0001 \le A_i \le 1{,}000{,}000, each AiA_i is an integer)

Output

Print the value of ii for each kk over NN lines.

Hint

For NN data values x1,x2,…,xnx_1, x_2, \dots, x_n,

the mean mm is m=x1+x2+⋯+xnnm = \frac{x_1 + x_2 + \cdots + x_n}{n}

the variance VV is V=(x1−m)2+(x2−m)2+⋯+(xn−m)2nV = \frac{(x_1 - m)^2 + (x_2 - m)^2 + \cdots + (x_n - m)^2}{n}

the standard deviation σ\sigma is σ=V\sigma = \sqrt{V}.

Shortening "a car takes the side of its owner, Kim Pyojun" to four characters gives "standard deviation." (hehe;; sorry.. lol!!)

Examples1

  1. Example 1

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