import java.util.*;

public class Main{
    static Scanner in = new Scanner(System.in);
    public static void solve(){
        int n = in.nextInt();
        long []a = new long[n + 1];
        for(int i = 1;i <= n;i++) a[i] = in.nextInt();
        Arrays.sort(a, 1, n+1);
        long all = 0;
        long nxt = 0;
        for(int i=1;i<=n;i++){
            a[i] += all+nxt;
            nxt = 0;
            if(a[i] < 0){
                all += a[i];
            }
            else{
                nxt += a[i];
            }
        }
        System.out.println(a[n]);
    }
    public static void main(String[] args){
        int T = in.nextInt();
        for(;T > 0;T--){
            solve();
        }
    }
}