P5216 DLS Picking Flowers.
Background
A very easy check-in problem.
Description
DLS has $N$ flower fields, and the $i$-th field has $a_i$ flowers.
DLS likes strange and unusual flower fields. He wants to rearrange the fields and then pick flowers.
However, DLS has another habit when picking flowers: he picks from left to right.
When he reaches the $i$-th field, if among the fields before it there is a field whose number of flowers is a divisor of the number of flowers in the $i$-th field, then DLS will not pick any flowers from this field.
Now, DLS wants to know, over all permutations of the fields, what the total sum of the number of flowers he can pick is.
Since the answer can be large, output it modulo $998244353$.
Input Format
The first line contains a positive integer $N$.
The second line contains a sequence $a$ of length $N$.
Output Format
Output one line: the sum of the number of flowers picked over all permutations, modulo $998244353$.
Explanation/Hint
|Data Percentage|Constraints|
|-|-|
|$50\%$|$N \le 9$|
|$80\%$|$N \le 1000$|
|$100\%$|$N \le 10^5, a_i \le 10^5$|
Translated by ChatGPT 5