Question and Answer from L4-M2
t = int(input())
for _ in range(t):
n = int(input())
l = list(map(int, input().split()))
m = [l[0]]
for i in range(1, n):
m.append(m[-1] + l[i])
print(sum(m[1:]))