5492: K-Yiwen with Formula

内存限制:128 MB 时间限制:60.000 S
评测方式:文本比较 命题人:
提交:12 解决:2

题目描述

Given an array a of length n, for any array b satisfying 1≤bi≤n and b1<b2<⋯<bk (k is the length of bk≥1), calculate:

输入

The input consists of multiple test cases.

The first line contains an integer T (1≤T≤10) -- the number of test cases.

For each test case:

The first line contains an integer n (1≤n≤10^5), which is the length of a.

The second line contains n integers ai (0≤ai≤10^5), which is the array a.

It is guaranteed that:
- The sum of n over all test cases will not exceed 2.5×10^5.
- The sum of ai in a single test will not exceed 10^5.
- The sum of ai over all test cases will not exceed 4×10^5.

输出

For each test case, output the result modulo 998244353 in a single line.

样例输入 复制

3
2
1 1
3
1 1 2
5
4 6 9 1 5

样例输出 复制

2
144
417630946