#include <bits/stdc++.h>
using namespace std;
const int INF32 = 1E9;
const long long INF64 = 4E18;
const long long M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (T x : p) os << x << " ";
  os << "]" << '\n';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "{ ";
  for (T x : p) os << x << " ";
  os << "}" << '\n';
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const map<Tk, Tv>& p) {
  os << "{ ";
  for (pair<Tk, Tv> x : p) os << x << " ";
  os << "}" << '\n';
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const pair<Tk, Tv>& p) {
  os << "{" << p.first << ',' << p.second << "}";
  return os;
}
int n;
vector<long long> a;
vector<vector<pair<long long, long long> > > dp;
pair<long long, long long> f(int ind, bool turn) {
  pair<long long, long long>& ret = dp[ind][turn];
  if (ind == n) {
    if (turn == 0) {
      ret = {a[n], 0};
      return ret;
    } else {
      ret = {0, a[n]};
      return ret;
    }
  }
  if (ret != pair<long long, long long>(-1, -1)) {
    return ret;
  }
  pair<long long, long long> x = f(ind + 1, !turn);
  if (turn == 0) {
    x.first += a[ind];
  } else {
    x.second += a[ind];
  }
  pair<long long, long long> y = f(ind + 1, turn);
  if (turn == 0) {
    y.second += a[ind];
  } else {
    y.first += a[ind];
  }
  if (turn == 0) {
    if (x.first != y.first) {
      if (x.first > y.first) {
        ret = x;
      } else {
        ret = y;
      }
    } else {
      if (x.second < y.second) {
        ret = x;
      } else {
        ret = y;
      }
    }
  } else {
    if (x.second != y.second) {
      if (x.second > y.second) {
        ret = x;
      } else {
        ret = y;
      }
    } else {
      if (x.first < y.first) {
        ret = x;
      } else {
        ret = y;
      }
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("tupni.txt", "r")) {
    freopen("tupni.txt", "r", stdin);
    freopen("tuptuo.txt", "w", stdout);
  }
  cin >> n;
  a.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  dp.assign(n + 5, vector<pair<long long, long long> >(
                       2, pair<long long, long long>(-1, -1)));
  cout << f(1, 0).second << " " << f(1, 0).first << '\n';
  return 0;
}
