// Problem F: Wrestling Teams Selection
// WrestlingTeams.java
// Andrew Davison, ad@fivedots.coe.psu.ac.th, August 2009
// ACM-ICPC Thailand 2009 Problem


import java.util.*;


public class WrestlingTeams
{
  private final static int MAX_WEIGHT = 450;
  private final static int MAX_PEOPLE = 100;
  private final static int MAX_TOTAL_WEIGHT = MAX_WEIGHT * MAX_PEOPLE;


  public static void main(String[] args) 
  {
    Scanner in = new Scanner(System.in);  
    int numPeople = in.nextInt(); 

    int[] personWeight = new int[MAX_PEOPLE];
    int totalWeight = 0;
    for (int i=0; i < numPeople; i++) {
      personWeight[i] = in.nextInt();
      totalWeight += personWeight[i];
    }

    int teamSize = numPeople/2;
    boolean[][] isPossible = possibleWeights(personWeight, teamSize, numPeople);
            // <number of people> <total weight> is possible

    int team1Weight = findTeamBestWeight(isPossible, teamSize, totalWeight);

    // print two team weights
    System.out.println(team1Weight + " " + (totalWeight-team1Weight));   
  }  // end of main()



  private static boolean[][] possibleWeights(int[] personWeight, 
                                              int teamSize, int numPeople)
  {
     boolean[][] isPossible = new boolean[MAX_PEOPLE+1][MAX_TOTAL_WEIGHT+1];
            // <number of people> <total weight> is possible

     isPossible[0][0] = true;
     for (int i=0; i < numPeople; i++) {  // try every person
       for (int j = teamSize; j >= 0; j--) {
         for (int w = MAX_TOTAL_WEIGHT; w >= 0; w--) {
           if (isPossible[j][w]) 
             isPossible[j+1][w + personWeight[i]] = true;
         }
       }
     }
     return isPossible;
  }  // end of possibleWeights()



  private static int findTeamBestWeight(boolean[][] isPossible, 
                                               int teamSize, int totalWeight)
  { int teamBestWeight = 0;
    for (int w=0; w <= MAX_TOTAL_WEIGHT; w++) {
      if (!isPossible[teamSize][w])   // look for team weight
        continue;
      // store weight w that is closest to half of total weight
      if (Math.abs(totalWeight-(2*w)) < Math.abs(totalWeight-(2*teamBestWeight))) 
        teamBestWeight = w;
    }

    // make teamBestWeight the lesser of the two team weights
    int team2Weight = totalWeight-teamBestWeight;
    if (teamBestWeight > team2Weight) 
      teamBestWeight = team2Weight;

    return teamBestWeight;
  }  // end of findTeamBestWeight()


}  // end of WrestlingTeams class

