跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1686. A Heap of Heaps

    ID: 1692 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>枚举数据结构数学排序算法思想编程与模拟提高难度共享题库Codeforces英文题面题目来源题面语言

A Heap of Heaps

题目描述

F. A Heap of Heaps
time limit per test
3 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment.

The teacher gave Andrew an array of n numbers a1, ..., an. After that he asked Andrew for each k from 1 to n-1 to build a k-ary heap on the array and count the number of elements for which the property of the minimum-rooted heap is violated, i.e. the value of an element is less than the value of its parent.

Andrew looked up on the Wikipedia that a k-ary heap is a rooted tree with vertices in elements of the array. If the elements of the array are indexed from 1 to n, then the children of element v are elements with indices k(v-1)+2, ..., kv+1 (if some of these elements lie outside the borders of the array, the corresponding children are absent). In any k-ary heap every element except for the first one has exactly one parent; for the element 1 the parent is absent (this element is the root of the heap). Denote p(v) as the number of the parent of the element with the number v. Let's say that for a non-root element v the property of the heap is violated if av<ap(v).

Help Andrew cope with the task!

Input

The first line contains a single integer n (2≤n≤2·105).

The second line contains n space-separated integers a1, ..., an (-109ai≤109).

Output

in a single line print n-1 integers, separate the consecutive numbers with a single space − the number of elements for which the property of the k-ary heap is violated, for k=1, 2, ..., n-1.

Examples
Input
5
1 5 4 3 2
Output
3 2 1 0
Input
6
2 2 2 2 2 2
Output
0 0 0 0 0
Note

Pictures with the heaps for the first sample are given below; elements for which the property of the heap is violated are marked with red.

In the second sample all elements are equal, so the property holds for all pairs.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1225 题。保留原作者与原赛事署名。