import scala.io.StdIn.{readInt, readLine}
  
object Main extends App {
  val (_, list) = (readInt, readLine.split(" ").map(_.toInt))
  val (mod1, mod2, mod0) = ( list.count(_%3==1), list.count(_%3==2), list.count(_%3==0) )
  val (m1, m2, m0) = if(mod1>mod2) (mod1, mod2, mod0) else (mod2, mod1, mod0)
  val diff = m1-m2
  val count0 = m2 * 2 + (if(diff <= 3) diff else 3)
  val count = count0 + (if(count0==0) 1 else  mod0)
  println(count)
}
