This page is still under construction.

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

A Heap of Heaps

Time limit2sMemory limit512 MB

Summary
For every k from 1 to n-1, treat the array as a k-ary heap and count how many nodes are smaller than their parent.
Level

Medium7 of 10

Topics
Math, Brute force, Implementation
Solved
No attempts yet

Problem

You are given a sequence of n integers a1,a2,…,ana_1, a_2, \dots, a_n. Take the sequence as the node values of a k-ary heap and count the nodes that break the min-heap property.

A k-ary heap is a rooted tree in which an internal node has at most k children. The nodes are numbered 1 to n and node 1 is the root. Node v has nodes k(v−1)+2k(v-1)+2, k(v−1)+3k(v-1)+3, …\dots, kv+1kv+1 as its children. A child whose number is greater than n does not exist, so only the last internal node can have fewer than k children.

Let p(v)p(v) be the parent of a node v that is not the root. Node v breaks the min-heap property when av<ap(v)a_v < a_{p(v)}. For each k=1,2,…,n−1k = 1, 2, \dots, n-1, count the nodes that break the property.

Input

The first line contains an integer n (1≤n≤2000001 \le n \le 200000).

The second line contains the n integers a1,a2,…,ana_1, a_2, \dots, a_n of the sequence, separated by spaces (−109≤ai≤109-10^9 \le a_i \le 10^9).

Output

Print n−1n-1 integers on one line, separated by single spaces. The ii-th number is the count of nodes that break the min-heap property in the ii-ary heap. When n=1n = 1 there is no such k, so print nothing.

Note

The pictures below show the heaps for k=1,2,3,4k = 1, 2, 3, 4 when n=5n = 5 and the sequence is 1 5 4 3 21\ 5\ 4\ 3\ 2. The red nodes break the min-heap property.

Examples8

  1. Example 1

    Input
    5
    1 5 4 3 2
    
    Expected output
    3 2 1 0
    
  2. Example 2

    Input
    1
    7
    
    Expected output
  3. Example 3

    Input
    2
    1 2
    
    Expected output
    0
    
  4. Example 4

    Input
    2
    5 3
    
    Expected output
    1
    
  5. Example 5

    Input
    6
    4 4 4 4 4 4
    
    Expected output
    0 0 0 0 0
    
  6. Example 6

    Input
    8
    8 7 6 5 4 3 2 1
    
    Expected output
    7 7 7 7 7 7 7
    
  7. Example 7

    Input
    10
    -3 -3 5 -1000000000 0 7 -3 1000000000 -1 2
    
    Expected output
    3 2 3 2 1 1 1 1 1
    
  8. Example 8

    Input
    12
    5 1 9 1 3 8 2 7 4 6 0 3
    
    Expected output
    5 5 6 6 5 5 5 6 6 6 7