#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long MAX = LONG_LONG_MAX;
const double pi = 3.1415926535897932384626433832;
const long long M = 1e9 + 7;
const long long Node = 2e5 + 7;
vector<long long> adj[Node];
long long vis[Node];
long long vis1[Node];
long long L[Node], R[Node];
void addedge(long long u, long long v) {
  adj[u - 1].push_back(v - 1);
  adj[v - 1].push_back(u - 1);
}
void dfs(long long u) {
  vis[u] = 1;
  for (auto x : adj[u]) {
    if (!vis[x]) {
      dfs(x);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long a1 = 0, b1 = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (a1 >= b1) {
      b1 += a[i];
    } else
      a1 += a[i];
  }
  cout << min(a1, b1) << " " << max(a1, b1) << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
