#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;long long x, p, q;vector<long long> a;bool b = 1;
int main()
{
    scanf("%d", &n);
    for(int i = 1;i <= n;++i)
        scanf("%lld", &x), a.push_back(x);
    sort(a.begin(), a.end());
    while(a.size())
    {
        if(b)
        {
            auto g = upper_bound(a.begin(), a.end(), p);
            if(g == a.begin()) p += a[0], a.erase(a.begin());
            else p += *(--g), a.erase(g);
        }
        else
        {
            auto g = upper_bound(a.begin(), a.end(), q);
            if(g == a.begin()) q += a[0], a.erase(a.begin());
            else q += *(--g), a.erase(g);
        }
        b ^= 1;
    }
    printf("%lld %lld", p, q);
    return 0;
}

0 条评论

目前还没有评论...