
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  val numbers = readLine.trim.split(' ').map(_.toInt).toList
  implicit val memo = Array.tabulate(21){_ ⇒ 0L}.also{_(numbers.head) = 1L}
  println(
    calPattern(numbers.tail)
  )
  def calPattern(numbers: List[Int])(implicit memo: Array[Long]): Long = {
    numbers match {
      case Nil ⇒ ???
      case h::Nil ⇒ memo(h)
      case h::t ⇒
        val add = (0 to (20 - h)).map{case i ⇒ memo(i)}
        val sub = (h to 20).map{case i ⇒ memo(i)}
        memo.indices.foreach(i ⇒ memo(i) = 0L)
        for (i ← 0 to (20 - h)){
          memo(i + h) += add(i)
        }
        for (i ← h to 20){
          memo(i - h) += sub(i - h)
        }
        calPattern(t)
    }
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

