object Main extends App {
  val n = io.StdIn.readInt
  val score = Iterator.continually(io.StdIn.readInt)
    .take(n)
    .toArray

  val ans = {
    var max = 0
    val a = Array.ofDim[Int](n)

    def evaluation():Unit = {
      val ai = a.iterator
      val res0 = score./:(0)((acc, e) => acc + e * ai.next)
      val res = if(res0 % 10 == 0) 0 else res0
      if(max < res) max = res
    }

    def rec(cnt:Int, end:Int):Unit = {
      if(cnt == end) evaluation()
      else {
        a(cnt) = 0; rec(cnt+1,n)
        a(cnt) = 1; rec(cnt+1,n)
      }
    }

    rec(0, n)
    max
  }

  println(ans)
}