import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import javafx.scene.shape.TriangleMesh;

/**
 *
 * @author USER
 */
public class Cf {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    
    static class BufPrint
    {
        final BufferedWriter bw;
        public BufPrint()
        {
            this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
        }
        public void print(Object object)throws IOException
        {
            bw.append(""+object);
        }
        public void println(Object object)throws IOException
        {
            print(object);
            bw.append("\n");
        }
        public void close()throws IOException
        {
            bw.close();
        }
    }
    

        public static int GCD(int l,int r) {
        int gcd=1;
        for(int i = 1; i <= l && i <= r; ++i)
        {
            // Checks if i is factor of both integers
            if(l % i==0 && r % i==0)
                gcd = i;
        }
    return gcd;
}
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        // TODO code application logic here
        
            FastReader sc=new FastReader(); 
            BufPrint bp=new BufPrint();
          
                int t=sc.nextInt();
                
                
                for(int k=0;k<t;k++){
                    
                int n=sc.nextInt();
                
                int[] a=new int[n];
                int pos=0;
                int neg=Integer.MIN_VALUE;
                long sum=0;
                boolean posp=true;
                boolean negp=true;
                int c=0;
                int last=0;
                boolean prevpos=false;
                boolean prevneg=false;
                for(int i=0;i<n;i++)
                {
                    a[i]=sc.nextInt();
                    if(a[i]>0)
                    {
                        if(prevpos==false)
                        {
                            pos=a[i];
                            prevpos=true;
                            prevneg=false;
                            sum=sum+a[i];
                            c++;
                            last=pos;
                        }
                        else
                        {
                            if(a[i]>pos){
                            sum=sum-pos;
                            pos=a[i];
                            sum=sum+pos;
                            prevpos=true;
                            prevneg=false;
                            c--;
                            c++;
                            last=pos;
                            }
                        }
                    }
                    else if(a[i]<0){
                        if(prevneg==false)
                        {
                            neg=a[i];
                            prevneg=true;
                            prevpos=false;
                            sum=sum+neg;
                            c++;
                            last=neg;
                        }
                        else
                        {
                            if(a[i]>neg){
                            sum=sum-neg;
                            neg=a[i];
                            sum=sum+neg;
                            prevneg=true;
                            prevpos=false;
                            c--;
                            c++;
                            last=neg;
                            }

                        }
                    }

                }
                if(c%2!=0)
                {
                    if(c>1){
                    sum=sum-last;
                    bp.println(sum);
                    }
                    else
                    {
                        bp.println(-1);
                    }
                }
                else
                {
                    if(c>1){
                    bp.println(sum);
                    }
                    else
                    {
                        bp.println(-1);
                    }
                }
                
                }



                bp.close();
            
    }
}