Cities
题号:NC15929
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld

题目描述

There are  cities in Byteland, and the  city has a value . The cost of building a bidirectional road between two cities is the sum of their values. Please calculate the minimum cost of connecting these cities, which means any two cities can reach each other.

输入描述:

The first line is an integer 
representing the number of test cases.

For each test case, the first line is an integer ,  representing the number of cities, the
second line are  positive integers ,
representing their values.

输出描述:

For each test case, output an integer, which is the
minimum cost of connecting these cities.
示例1

输入

复制
2
4
1 2 3 4
1
1

输出

复制
12
0