t=int(input())
for k in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    su=0
    sa=0
    for i in range(1,n):
        for j in range(i+1,n):
            su+=a[i]
            sa+=a[j]
    print(su,sa)