[SOLUTION] Summing the values SOLUTION CODECHEF

Problem SOLUTION CODECHEF For an array �B of length �M, we define its value �(�)f(B) as follows: �(�)=∑�=1�−1((∑�=1���)−(∑�=�+1���))f(B)=i=1∑M−1​((j=1∑i​Bj​)−(j=i+1∑M​Bj​)) In particular, if �=1M=1 then �(�)=0f(B)=0. You’re given an array �A of length �N. Find the sum of values of all of its subarrays. That is, compute ∑�=1�∑�=���(�[�…�])L=1∑N​R=L∑N​f(A[L…R]) where �[�…�]A[L…R] denotes the subarray [��,��+1,��+2,…,��][AL​,AL+1​,AL+2​,…,AR​]. The answer can be large, so print it modulo 998244353998244353. Input Format The first line of input will contain a single … Read more