This page is still under construction.

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

Patting Heads

Time limit1sMemory limit128 MB

Summary
Each of N cows has a value; for every cow count how many other cows hold a value that divides hers.
Level

Medium5 of 10

Topics
Math, Number theory, Hash map, Array
Solved
No attempts yet

Problem

It's Bessie's birthday, and it's time for party games! Bessie has arranged the NN cows (1≤N≤1000001 \le N \le 100000), conveniently numbered 1…N1 \dots N, in a circle, so that cow ii sits between cows i−1i-1 and i+1i+1, and cow NN sits next to cow 11.

Farmer John fills a barrel with a huge number of paper slips, each holding an integer between 11 and 10000001000000. Each cow ii then draws one integer AiA_i (1≤Ai≤10000001 \le A_i \le 1000000) from the barrel; the values are not necessarily distinct.

Taking turns, each cow ii walks around the circle and pats the head of every other cow jj whose number AjA_j exactly divides her own number AiA_i, then returns to her seat.

For each cow, determine how many other cows she pats.

Input

  • Line 11: a single integer NN.
  • Lines 2…N+12 \dots N+1: line i+1i+1 contains the integer AiA_i.

Output

  • Print NN lines. On line ii, print a single integer: the number of other cows that cow ii pats.

Hint

In the example, the first cow (number 22) pats the second cow (number 11, since 22 is divisible by 11) and the third cow (number 22), for a total of 22. The second cow (number 11) pats no one, because no other cow drew a number that divides 11.

Examples2

  1. Example 1

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

    Input
    4
    1
    2
    4
    8
    
    Expected output
    0
    1
    2
    3