#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t,n,a[100001],s[100001],Max,sum,Min[100001],Max2;
cin >> t;
for (int i=1;i<=t;i++)
{
Max=INT_MIN;
sum=0;
cin >> n;
s[0]=0;
Min[0]=0;
Max2=a[1];
for (int i=1;i<=n;i++)
{
cin >> a[i];
s[i]=s[i-1]+a[i];
if (a[i]>Max) Max=a[i];
if (a[i]>0) sum+=a[i];
Min[i]=min(Min[i-1],s[i]);
Max2=max(Max2,s[i]-Min[i-1]);
}
if (sum==0) cout << Max;
else cout << sum;
cout << ' ' << Max2 << '\n'
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int oo = 1000000007;
int nTest, n, a[MAXN];
int task1() {
int res = 0;
bool allNegative = true;
for(int i = 0; i < n; ++i) {
if (a[i] >= 0) {
allNegative = false;
res += a[i];
}
}
if (allNegative)
res = *max_element(a, a+n);
return res;
}
int task2() {
int sum = 0, res = -oo;
for(int i = 0; i < n; ++i) {
sum = sum + a[i];
res = max(res, sum);
sum = max(sum, 0);
}
return res;
}
int main() {
scanf("%d", &nTest);
while (nTest--) {
scanf("%d", &n);
for(int i = 0; i < n; ++i)
scanf("%d", &a[i]);
printf("%d %d\n", task1(), task2());
}
}