
{ Solution made by Tomas Laurinavi‡ius (Panev‚‘io J. Bal‡ikonio gmn, 11kl., Lithuania)
   during the contest and was awarded full points }


{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S-,T-,V+,X+,Y+}
{$M 16384,0,655360}

  Var N : Word;
      pr : array[ 1..100 ] of Word;
      vl : array[ 1..200 ] of Word;
      fs : Word;

  Procedure ReadInput;
    Var InFile : Text;
        i : Word;
  begin
    Assign( InFile, 'DAY1C.DAT' );
    Reset( InFile );
    Read( InFile, N );
    fs := 0;
    FillChar( vl, 400, 0 );
    for i := 1 to N do begin
      Read( InFile, pr[ i ] );
      Inc( fs, pr[ i ] );
      Inc( vl[ pr[ i ] ] )
    end;
    Close( Infile )
  end;

  Function Found( Last, Sum : Integer ) : Boolean;
    Var i : Word;
  begin
    for i := Last downto 1 do
      if vl[ i ] > 0
         then if i < Sum
                 then begin
                        Dec( vl[ i ] );
                        if Found( i, Sum - i )
                           then begin
                                  Found := True;
                                  Exit
                                end;
                        Inc( vl[ i ] )
                      end
                 else if i = Sum
                         then begin
                                Found := True;
                                Exit
                              end;
    Found := False
  end;

  Procedure Calculate;
    Var half : Word;
        OutFile : Text;
  begin
    half := fs div 2;
    While not Found( 200, half ) do
      Dec( half );
    Assign( OutFile, 'DAY1C.SOL' );
    ReWrite( OutFile );
    WriteLn( OutFile, half, ' ', fs - half );
    Close( OutFile )
  end;

Begin
  ReadInput;
  Calculate
End.