#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     int ar[1000];     int i;     for (i = 0; i < n; scanf( %d , &ar[i++]))       ;     int b = 0, e = n - 1;     int s = 0, d = 0;     i = 1;     while (b <= e) {       if (ar[b] > ar[e]) {         if (i == 1)           s = s + ar[b];         else           d = d + ar[b];         b++;       } else {         if (i == 1)           s = s + ar[e];         else           d = d + ar[e];         e--;       }       i = i * -1;     }     printf( %d %d , s, d);     exit(0);   }   