#include using namespace std; // ----- TYPES ----- typedef long long ll; typedef pair pii; typedef vector vi; // ----- FILE IO ----- #define STDIN(filename) freopen(filename, "r", stdin) #define STDOUT(filename) freopen(filename, "w", stdout) #define FASTIO cin.tie(0)->sync_with_stdio(0) #define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str()) #define NL '\n' #define CM ", " #define SP ' ' // ----- FOR LOOPS ----- #define F(i,L,R) for (int i = L; i < R; i++) #define FE(i,L,R) for (int i = L; i <= R; i++) #define FD(i,L,R) for (int i = L; i > R; i--) #define FDE(i,L,R) for (int i = L; i >= R; i--) // ----- WEZ ----- #define takeI(n) int n; cin >> n #define takeII(n,m) int n, m; cin >> n >> m #define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k #define takeL(n) ll n; cin >> n #define takeS(s) string s; cin >> s #define takeV(v,n) vi v(n); for (auto &x : v) cin >> x #define takeVL(v,n) vector v(n); for (auto &x : v) cin >> x #define whileZ takeI(T); while(T--) // // ----- MAX MIN ----- #define REMAX(a,b) (a)=max((a),(b)) #define REMIN(a,b) (a)=min((a),(b)) // ----- PAIRS ----- #define fi first #define se second // ----- OUTPUT ----- #define YESNO(b) cout << ((b) ? "YES" : "NO") << NL // ----- DEBUG ----- #define DBG(vari) cerr<<#vari<<" = "<<(vari)<()) #define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end()) #define pb push_back int main() { FASTIO; takeI(t); while(t--) { takeI(n); takeV(a,n); // Bessie & elsie /** N = 2 Only bessie gets to take a turn N = 4 Bessie gets 2 turns, elsie gets 1 N = 6 B 1 1 1 1 1 1 E 1 1 2 1 1 B 1 1 2 1 E 1 3 1 B 1 3 E 4 Bessie gets 3 turns, elsie gets 2 B: 1, 2, 3, 4 E: 1, 5, 4 B: 1, 5 E, 6 B = 6, E = 4 */ // Calculate total ll total = 0; for (auto x : a) total += x; // Calculate if elsie just picks on the left int elsieTurns = (n/2) - 1; ll tmpTotal = 0; for (int i = 0; i < elsieTurns; i++) tmpTotal += a[i]; ll e = tmpTotal; for (int i = 0; i < elsieTurns; i++) { tmpTotal -= a[elsieTurns-1-i]; tmpTotal += a[n-1-i]; e = max(tmpTotal, e); } ll b = total - e; cout << b << SP << e << NL; } }