import scala.io.StdIn.readLine
import scala.math.{max, min}
import scala.annotation.tailrec

object Main extends App {

  readLine()

  val xs = readLine().split(" ").map { _.toLong }

  val (minV, maxV, sumV) = solve(xs)
  println(s"$minV $maxV $sumV")

  def solve(zs: Seq[Long]): (Long, Long, Long) = {

    @tailrec
    def go(xs: List[Long], t: (Long, Long, Long)): (Long, Long, Long) =
      xs match {
        case Nil     => t
        case y :: ys =>
          val (minV, maxV, sumV) = t
          go(ys, (min(y, minV), max(y, maxV), y + sumV))
      }

    val x :: xs = zs.toList
    go(xs, (x, x, x))
  }
}

