407335: GYM102767 A Favourite Sum

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Favourite Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a sequence of $$$n$$$ distinct favourite integers $$$a_1,a_2,a_3,\ldots,a_n$$$ and a number $$$x$$$.

Your task is to calculate the sum of all integers from $$$1$$$ to $$$x$$$, but you should take favourite integers with minus in the sum.

For example, $$$a = [1,4,6], x = 5$$$ the sum is equal to $$$- 1 + 2 + 3 - 4 + 5 = 5$$$, because $$$1$$$, $$$4$$$ are favourite integers. We don't consider $$$6$$$ in our sum as we have to take sum from $$$1$$$ to $$$x$$$ only.

Input

The first line contains a single integer $$$t (1 \le t \le 10^5)$$$ — the number of test cases in the input. Then $$$t$$$ test cases follow.

Each query contains two lines. The first line contains two integer $$$n (1 \le n \le 10^5)$$$: the number of favourite integers in the sequence and $$$ x (1 \le x \le 10^9 )$$$, and the second line contains $$$n$$$ distinct favourite integers $$$a_1, \ldots ,a_n (1\le a_i \le 10^9)$$$.

It is guaranteed that the total sum of $$$n$$$ is at most $$$10^5$$$ and all favourite integers are distinct.

Output

Print the requested sum for each of $$$t$$$ test case.

ExampleInput
3
3 5
1 4 6
3 3
2 3 4
3 1000000000
1 2 3
Output
5
-4
500000000499999988
Note

The answer for the first sample is explained in the statement.

The sum of second query is — $$$ +1 -2 - 3 = -4$$$.

加入题单

上一题 下一题 算法标签: