#include using namespace std; #define int long long typedef pair P; int INF = 3e18+7; int mod = 1e9+7; int dx[] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[] = {0, 1, 0,-1, 1,-1, 1,-1}; signed main() { int T; cin >> T; while (T--) { int N; cin >> N; vectorA(N); int sum = 0; for(int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } for(int i = 0; i < N; i++) { for(int j = i+1; j < N; j++) { sum += A[i]*A[j]; } } cout << sum << endl; } }