{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDreamGrid正在驾驶一艘飞船从火星飞往地球。\u003c/p\u003e\u003cp\u003e在飞船加速的轨迹上有$$$n$$$个加速器,第$$$i$$$个加速器的加速系数为$$$a_i$$$。飞船将逐个经过这些加速器。初始时,飞船的速度为$$$0$$$。当飞船经过一个加速器时,它会从加速器获得能量,速度会发生变化。具体来说,如果加速系数为$$$A$$$,加速前的速度为$$$v$$$,那么加速后的速度变为$$$v\u0027\u003d(v+1)\\times A$$$。\u003c/p\u003e\u003cp\u003e然而,这$$$n$$$个加速器被均匀随机打乱了顺序。DreamGrid现在不知道经过的加速器顺序。你能告诉他经过所有$$$n$$$个加速器后的期望速度吗?\u003c/p\u003e\u003cp\u003e可以证明期望速度是有理数的。假设答案可以表示为$$$\\frac{u}{d}$$$,其中$$$\\gcd(u, d) \u003d 1$$$,你需要输出一个整数$$$r$$$,使得$$$rd \\equiv u\\pmod{998\\,244\\,353}$$$且$$$0 \\le r \u0026lt; 998\\,244\\,353$$$。可以证明这样的$$$r$$$存在且唯一。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e有多个测试用例。输入的第一行包含一个整数$$$T$$$($$$1 \\le T \\le 100\\,000$$$),表示测试用例的数量。对于每个测试用例:\u003c/p\u003e\u003cp\u003e第一行包含一个整数$$$n$$$($$$1 \\le n \\le 100\\,000$$$),表示加速器的数量。\u003c/p\u003e\u003cp\u003e接下来一行包含$$$n$$$个整数$$$a_1, a_2, \\cdots, a_n$$$($$$1 \\le a_i \\le 10^9$$$),表示加速器的加速系数。\u003c/p\u003e\u003cp\u003e保证所有测试用例的$$$n$$$之和不超过$$$100\\,000$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对每个测试用例输出一行,包含整数$$$r$$$。\u003c/p\u003e"}},{"title":"示例1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n3\n1 2 3\n1\n10\n4\n5 5 5 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e665496247\n10\n780\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e对于第一个示例,有$$$6$$$种方式来排列加速器:\u003c/p\u003e\u003cul\u003e \u003cli\u003e [1,2,3]: $$$v \u003d ((((0+1)\\times 1+1)\\times 2)+1)\\times 3 \u003d 15$$$ \u003c/li\u003e\u003cli\u003e [1,3,2]: $$$v \u003d ((((0+1)\\times 1+1)\\times 3)+1)\\times 2 \u003d 14$$$ \u003c/li\u003e\u003cli\u003e [2,1,3]: $$$v \u003d ((((0+1)\\times 2+1)\\times 1)+1)\\times 3 \u003d 12$$$ \u003c/li\u003e\u003cli\u003e [2,3,1]: $$$v \u003d ((((0+1)\\times 2+1)\\times 3)+1)\\times 1 \u003d 10$$$ \u003c/li\u003e\u003cli\u003e [3,1,2]: $$$v \u003d ((((0+1)\\times 3+1)\\times 1)+1)\\times 2 \u003d 10$$$ \u003c/li\u003e\u003cli\u003e [3,2,1]: $$$v \u003d ((((0+1)\\times 3+1)\\times 2)+1)\\times 1 \u003d 9$$$ \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e因此,期望速度为$$$\\frac{15+14+12+10+10+9}{3!} \u003d \\frac{70}{6}$$$。\u003c/p\u003e"}}]}