#include<iostream>
#include<set>
using namespace std;
int main(){
int n,b[100000+5],summax=0,summin=0;
set<int> s;
cin>>n;
for(int i=0;i<n;i++){
cin>>b[i];
s.insert(b[i]);
summax += b[i];
}
for(set<int>::iterator it=s.begin();it!=s.end();it++){
summin += (*it);
}
cout<<summax<<"\n"<<summin;
return 0;
}