Minimal Cyclic Shift

아직 제출이 없습니다시간 제한1.5초메모리 제한256 MB

문제

Ani is a young and reckless student. One day, he got a really weird math homework.

In the homework, he was given nn strings s_1,s_2,,s_ns\_1, s\_2, \ldots, s\_n with length a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n, respectively.

Define f(s)f(s) as the position where the lexicographically minimal cyclic shift of ss starts. Since it may not be unique, f(s)f(s) is defined as the minimal such position. For example, f(f("qweqweqwe")=3) = 3, because the lexicographically minimal cyclic shift of s=s = "qweqweqwe" is "eqweqweqw", and the minimal possible position where it starts in ss is position 33 where the first letter "e" is located.

The homework was to write down f(s_1),f(s_2),f(s_3),,f(s_n)f(s\_1), f(s\_2), f(s\_3), \ldots, f(s\_n), in this order. But Ani's recklessness and the approaching of the deadline caused him to write the answers in the order f(s_n),f(s_1),f(s_2),,f(s_n1)f(s\_n), f(s\_1), f(s\_2), \ldots, f(s\_{n-1}).

Ani had not realized this until he submitted his answers. Now he can only remember a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n. Assuming the given strings contain only lowercase English letters and were generated uniformly at random by the teacher, you need to help him calculate the expected number of correct answers in his homework modulo 998,244,353998\\,244\\,353.

입력

The first line of input contains an integer nn (1n1051 \le n \le 10^5), the number of strings given in Ani's homework.

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (1a_i1051 \le a\_i \le 10^5) separated by spaces, indicating the lengths of the strings.

출력

Print a single line with an integer: the expected number of correct answers in Ani's homework modulo 998,244,353998\\,244\\,353.

Formally, it can be shown that the expected number of correct answers can be represented as a fraction p/qp / q for some coprime non-negative integers pp and qq. You have to print the value pq1mod998,244,353p \cdot q^{-1} \bmod 998\\,244\\,353.