#include <bits/stdc++.h>   using namespace std;   int compare(const void *a, const void *b) {     int A = *((int *)a);     int B = *((int *)b);     return B - A;   }   int main() {     long long a[200000], b, c = 0, d, f = 0, i, j, k, n, m, p = 0, q = 0, r,                             t = 0, l, mid = 0, sum = 0, x, y, s = 0;     string ch[3000][2];     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     i = 0;     j = n - 1;     while (i <= j) {       c++;       if (c % 2 != 0) {         if (a[i] > a[j]) {           s = s + a[i];           i++;         } else {           s = s + a[j];           j--;         }       } else {         if (a[i] > a[j]) {           f = f + a[i];           i++;         } else {           f = f + a[j];           j--;         }       }     }     cout << s <<     << f;   }   