Under construction

Still being built. Things may change

The Lifesaving Riddle

Interview

Time limit1sMemory limit1024 MB

Summary
For each shift x from 1 to n-1, decide whether some array a can produce the given difference array b under a left cyclic shift.
Level

Medium5 of 10

Topics
Math, Number theory, Array
Solved
No attempts yet

Problem

The Riddler kidnaps Gil Colson, the district attorney.

To escape, Colson must solve three riddles. Batman helps him with the first two, but the third one is too hard. Can you help him solve it?

The riddle works as follows:

  1. The Riddler writes down and hides an integer array aa of length nn.
  2. He then cyclically shifts it left by some amount xx, and subtracts the shifted array from the original element by element.
  3. The resulting array bb (that is, the array with bi=ai−a(i+x) mod nb_i = a_i - a_{(i + x) \bmod n} for all ii) is given to Colson.

Given array bb, restore all possible shift values xx that could produce bb from some array aa.

Input

The first line contains a single integer nn, the length of the original array (1⩽n⩽1061 \leqslant n \leqslant 10^6).

The second line contains nn integers b1,b2,…,bnb_1, b_2, \ldots, b_n separated by spaces, the elements of the array bb that the Riddler gave (∣bi∣⩽109|b_i| \leqslant 10^9).

Output

Print n−1n - 1 integers separated by spaces. The ii-th of them is 1 if x=ix = i could have occurred, and 0 otherwise.

Hints

In the first example, the array bb could come from a=[2,4,4]a = [2, 4, 4] shifted left by 1, or from a=[2,2,4]a = [2, 2, 4] shifted left by 2.

In the first example, this array bb could not come from any aa shifted by 3, while shifts 1 or 4 work, for example with a=[1,2,0,3,7,3]a = [1, 2, 0, 3, 7, 3] and a=[3,7,0,3,4,5]a = [3, 7, 0, 3, 4, 5] respectively.

For the third example, one can show that such bb could not have been produced in the way described in the statement.

Examples3

  1. Example 1

    Input
    3
    -2 0 2
    
    Expected output
    1 1
    
  2. Example 2

    Input
    6
    -1 2 -3 -4 4 2
    
    Expected output
    1 1 0 1 1
    
  3. Example 3

    Input
    7
    -1 1 -1 1 -1 1 -1
    
    Expected output
    0 0 0 0 0 0