#P8016. Candy Sharing Socialization

    ID: 21200 Type: Default 1000ms 256MiB

Candy Sharing Socialization

Candy Sharing Socialization

Mirko holds (N) parties and prepares (N) tables. On the (i)-th party, he invites (i) people to each table. The (j)-th table contains (V_j) candies. When everyone is seated, the candies on table (j) are equally shared, i.e. each person receives (\left\lfloor \frac{V_j}{i} \right\rfloor) candies. Note that the candy supply is refreshed every day, so sharing does not deplete it.

A table is considered to be "socializing" if there is at least one other table that yields the same number of candies per person (i.e. the same value of (\left\lfloor \frac{V_j}{i} \right\rfloor)).

For each integer (s) from (1) to (N), your task is to determine the earliest party day (in the range (1) to (N)) on which exactly (s) tables are socializing. If no such day exists, output (-1) for that (s).

inputFormat

The input consists of two lines:

  • The first line contains a single integer \(N\) representing the number of parties and tables.
  • The second line contains \(N\) space-separated integers \(V_1, V_2, \ldots, V_N\) where \(V_j\) represents the number of candies on the \(j\)-th table.

outputFormat

Output a single line containing \(N\) space‐separated integers. The \(s\)-th integer corresponds to the earliest day (from \(1\) to \(N\)) on which exactly \(s\) tables are socializing. If no such day exists for a particular \(s\), output \(-1\) for that position.

sample

3
1 2 3
-1 2 -1