We are going to distribute apples to n children. Every child has his/her desired number of apple ${A_1},{A_2},{A_3}, \cdots {A_n}$ , ${A_i}$ indicates the i-th child’s desired number of apple. Those children should stand in a line randomly before we distribute apples. Assume that the i-th position is occupied by ${p_i} - th$ child, i.e. from left to right the id of the children are ${p_1},{p_2},{p_3}, \cdots {p_n}$,So their desired number of apple are ${A_{{p_1}}},{A_{{p_2}}},{A_{{p_3}}},
\cdots {A_{{p_n}}}$. We will distribute ${A_{{p_1}}}$ apples to the left most child,and for the i-th (i>1)child,if there exists a j which makes j < i and ${A_{p_j}} > {A_{{p_i}}}$ true, we will distribute no apples to him/her,otherwise we will distribute ${A_{{p_i}}}$ apples to him/ner. So for a certain permutation there exist a certain number of apples we should distribute. Now we want to know how many apples we should distribute for all possible permutation.
Note: two permutations are considered different if and only if there exists at least a position in which two children’s desired number of apple are different.