luogu#P5216. DLS 采花

DLS 采花

Background

A very easy check-in problem.

Problem Description

DLS has NN flower fields, and the ii-th field has aia_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 ii-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 ii-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 998244353998244353.

Input Format

The first line contains a positive integer NN.
The second line contains a sequence aa of length NN.

Output Format

Output one line: the sum of the number of flowers picked over all permutations, modulo 998244353998244353.

4
2 3 6 3

156

Hint

Data Percentage Constraints
50%50\% N9N \le 9
80%80\% N1000N \le 1000
100%100\% N105,ai105N \le 10^5, a_i \le 10^5

Translated by ChatGPT 5