#P1732. [TJOI2011] 序列
[TJOI2011] 序列
Description
Given a sequence , compute the sequence from , where:
$$b_i= \begin{cases} a_1 &, i=1 \\ \min_{1 \leq j < i}\left|a_i-a_j\right| &, i\gt 1 \end{cases}$$Find .
Input Format
The first line contains a positive integer , the number of testdata sets. Then there are lines, each describing one set of testdata. Each line starts with a positive integer , the number of elements in sequence ; then follow non-negative integers, which are in order.
Output Format
For each testdata set, output the sum of all elements of sequence .
2
5 1 2 3 4 5
7 2 9 7 4 6 2 6
5
14
Hint
Constraints: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号