#include<bits/stdc++.h>
using namespace std;
int n;
long long a[1010];
long long f, b;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
if (i % 2 == 1) {
int t = 0;
for (int j = n; j > 0; j--)
if (a[j] <= f && a[j] != 0) t = j;
if (t == 0) {
for (int j = 1; j <= n; j++)
if (a[j] != 0) {
t = j;
break;
}
}
f += a[t];
a[t] = 0;
} else {
int t = 0;
for (int j = n; j > 0; j--)
if (a[j] <= b && a[j] != 0) t = j;
if (t == 0) {
for (int j = 1; j <= n; j++)
if (a[j] != 0) {
t = j;
break;
}
}
b += a[t];
a[t] = 0;
}
}
cout << f << " " << b;
return 0;
}
求帮助……不爱写注释望dalao宽恕……