
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  solve
  def solve: Unit ={
    val n = readLine.trim.toInt
    if (n == 0) return
    println(
      Array.tabulate(n / 4){_ ⇒ readLine.trim.toInt}.sum
    )
    solve
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
