object Main {

  def dis(a:List[Int],b:List[Int]) ={
    if(b(0)<b(1)){
      List(a(0),a(1)+b.sum)
    }else if(b(0)>b(1)){
      List(a(0)+b.sum,a(1))
    }else{
      List(a(0)+b(0),a(1)+b(1))
    }
  }

  def calc(sc:java.util.Scanner):Unit ={
    sc.nextInt match{
      case 0 =>
        Unit
      case n =>
        var ans = List.fill(n,2)(sc.nextInt).fold(List(0,0))(dis)
        printf("%d %d\n",ans(0),ans(1))
        calc(sc)
    }
  }

  def main(args:Array[String]) = {
    calc(new java.util.Scanner(System.in))
  }
}