#include <bits/stdc++.h>
struct node {
  int data;
  struct node *next, *last;
};
struct node *head, *x, *y;
int i, n;
void add() {
  head = x = y = NULL;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    x = new (node);
    if (head == NULL) {
      head = y = x;
      head->last = NULL;
    } else {
      y->next = x;
      x->last = y;
      y = x;
    }
    x->next = NULL;
    scanf("%d", &x->data);
  }
}
void calc() {
  x = head;
  while (x->next != NULL) {
    x = x->next;
  }
  int Sereja = 0, Dima = 0, c = 0;
  do {
    if (head->data > x->data && c % 2 == 0) {
      Sereja += head->data;
      head = head->next;
      head->last = NULL;
      ++c;
    } else if (head->data < x->data && c % 2 == 0) {
      Sereja += x->data;
      x = x->last;
      x->next = NULL;
      ++c;
    } else if (head->data == x->data && c % 2 == 0) {
      Sereja += x->data;
      break;
    }
    if (head->data > x->data && c % 2 != 0) {
      Dima += head->data;
      head = head->next;
      head->last = NULL;
      ++c;
    } else if (head->data < x->data && c % 2 != 0) {
      Dima += x->data;
      x = x->last;
      x->next = NULL;
      ++c;
    } else if (head->data == x->data && c % 2 != 0) {
      Dima += x->data;
      break;
    }
  } while (1);
  printf("%d ", Sereja);
  printf("%d", Dima);
}
int main() {
  add();
  calc();
}
