You are given an array X of N integers. We define the value of a subarray as the last element of the subarray. Find the sum of the value of all possible subarrays. A subarray is any contiguous part of the array.
Input Format:
Output format:
For each test case, print the sum of the value of all subarrays of the given array X.
Constraints:
1<=T<=10
1<=N<=105
1<=Xi<=105
For test case 1:
There are total 3 subarrays in the given array, i.e. [1],[3], and [1,3]. So, the answer is the sum of the last element of all subarrays.
Hence, the answer is 1+3+3=7.
For test case 2:
In this case, we can see all elements are equal to 1, so the last element of all subarrays of this array will always be equal to 1. So, the answer will be equal to the number of subarrays multiplied by 1.
Hence, the answer is 4∗(4+1)/2=10.