#coding: utf-8 ##yuki_297 import sys n=int(raw_input()) s=raw_input().split() ls=list(s) ls.sort() cnt_plus=ls.count('+') cnt_minus=ls.count('-') cnt=cnt_plus+cnt_minus cnt_plus2=cnt_plus cnt_minus2=cnt_minus while ls[0]=='+' or ls[0]=='-': del ls[0] while ls[0]=='0': del ls[0] ls.reverse() ls2=ls[:] #max res=0 while cnt_minus>0: res+=-int(ls.pop()) cnt_minus-=1 while cnt_plus>0: res+=int(ls.pop()) cnt_plus-=1 lsn=int("".join(ls)) res1=res+lsn #min res=0 if cnt_minus2==0: res2=res1 print res1,res2 sys.exit() if cnt_minus2>0: res+=int(ls2.pop()) cnt_minus2-=1 while cnt_plus2>0: res+=int(ls2.pop()) cnt_plus2-=1 while cnt_minus2>0: res-=int(ls2.pop()) cnt_minus2-=1 lsn=-int("".join(ls2)) res2=res+lsn print res1,res2