#include <bits/stdc++.h>
using namespace std;
int t[4][2] = {{0, -1}, {-1, 0}, {1, 0}, {0, 1}};
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
struct node {
  int num;
  int idx;
};
int run(int y) {
  if (y % 400 == 0) {
    return 1;
  }
  if (y & 100 == 0 && y % 4 == 0) {
    return 1;
  }
  return 0;
}
long long qpow(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) {
      ans = x * ans;
    }
    n = n >> 1;
    x *= x;
  }
  return ans;
}
long long lj(long long n) {
  long long sum = 0;
  for (int i = 0; i <= n; i++) {
    sum += i;
  }
  return sum;
}
long long jc(long long n, long long cnt) {
  long long sum = 1;
  while (cnt--) {
    sum *= n;
    n -= 1;
  }
  if (sum == 1) {
    return 0;
  }
  return sum;
}
int f[1000 * 1100];
int find(int u) {
  int tu = u;
  while (f[tu] != tu) {
    tu = f[tu];
  }
  return tu;
}
int combin(int x, int y) {
  int tx = find(x);
  int ty = find(y);
  if (tx == ty) {
    return 0;
  } else {
    f[tx] = ty;
    return 1;
  }
}
int flag[100010];
int prime[100010];
void pri() {
  int t = 0;
  flag[0] = 1;
  flag[1] = 1;
  for (int i = 2; i < 10000; i++) {
    if (!flag[i]) {
      prime[++t] = i;
    }
    for (int j = 1; j <= t && i * prime[j] <= 10000; j++) {
      flag[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        break;
      }
    }
  }
}
int dir[4] = {1, -1, 2, -2};
string str = "012345678", s = "087654321";
int ans = 400;
int book[1000][1000];
int mp[1000][1000];
map<string, int> m;
set<string> st;
queue<string> q;
void bfs() {
  q.push(str);
  while (!q.empty()) {
    string now = q.front();
    q.pop();
    if (now == s) {
      if (m[now] < ans) {
        ans = m[now];
      }
    }
    int dex;
    for (int i = 0; i < str.size(); i++) {
      if (now[i] == '0') {
        dex = i;
        break;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (dex + dir[i] >= 0 && dex + dir[i] < 9) {
        string nt = now;
        st.insert(nt);
        char t = nt[dex + dir[i]];
        nt[dex + dir[i]] = nt[dex];
        nt[dex] = t;
        if (!m[nt]) {
          m[nt] = m[now] + 1;
          q.push(nt);
        }
      }
    }
  }
}
int dfs(string str) {
  if (str.find("LOL") != string::npos) {
    return -1;
  }
  if (str.find("*") == string::npos) {
    return 0;
  }
  int p = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '*') {
      str[i] = 'L';
      int s = dfs(str);
      if (s == -1) {
        return 1;
      } else if (s == 0) {
        p = 1;
      }
      str[i] = 'O';
      s = dfs(str);
      if (s == -1) {
        return 1;
      } else if (s == 0) {
        p = 1;
      }
      if (p) {
        return 0;
      }
      str[i] = '*';
    }
  }
  if (p) {
    return 0;
  }
  return -1;
}
int a[10000];
int main(int argc, char** argv) {
  int x, y;
  int n;
  cin >> n;
  int a[n + 10];
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = 0, j = n - 1;
  while (i < j) {
    if (a[i] > a[j]) {
      sum1 += a[i];
      i++;
    } else {
      sum1 += a[j];
      j--;
    }
    if (a[i] > a[j]) {
      sum2 += a[i];
      i++;
    } else {
      sum2 += a[j];
      j--;
    }
  }
  if (i == j) {
    sum1 += a[i];
  }
  cout << sum1 << " " << sum2 << endl;
  return 0;
}
