#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define endl "\n"
vector<int> takeVectorInput(int n){
vector<int>v(n);
for(auto &ele:v)cin>>ele;
// vector<int>v(n+1);
// for(int i=1;i<=n;++i) {
// cin>>v[i];
// }
return v;
}
void solve(){
int n;
cin>>n;
auto v=takeVectorInput(n);
sort(v.begin(),v.end());
int i=0;
int j=n-1;
int ans=0;
bool completed=true;
while(i<j){
// if(v[i]!=-1)break;
if(v[i]==-1&&v[i+1]==-1){
ans+=v[j];
i+=2;
j--;
}
else{
completed=0;
break;
}
}
if(!completed){
while(j-2>=i){
ans+=v[j]*v[j-1]*v[j-2];
j-=3;
}
}
cout<<ans<<endl;
}
signed main(){
fast
int t;
cin>>t;
while(t--){
solve();
}
}