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) )
  var count = 0
  var (m1, m2, m0) = if(mod1>mod2) (mod1, mod2, mod0) else (mod2, mod1, mod0)
  while(m2>0) {
    if(m1>=2) {
      m1 -= 2
      count += 2
    } else if(m1==1) {
      m1 -= 1
      count += 1
    }
    m2 -= 1
    count += 1
    if(m0>0) {
      m0 -= 1
      count+=1
    }
  }
  if(m1>=2) {
      m1 -= 2
      count += 2
  } else if(m1==1) {
      m1 -= 1
      count += 1
  }
  if(m0>0 && mod2==0) { count+=1 }
  println(count)
}
