object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  val bills = readLine.trim.split(' ').map(_.toLong).sorted.toList

  println(solve(bills))
  def solve(bills: List[Long]): Long = {
    def sub(rest: List[Long], upper: Long): Long = {
      rest match {
        case Nil ⇒ upper
        case h::_ if upper < h ⇒ upper
        case h::t ⇒ sub(t, upper + h)
      }
    }
    sub(bills, 1)
  }
}
