object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val detective = readLine.trim.split(' ').map(_.toInt)
  val r0 = detective.count(_ % 3 == 0)
  val r1 = detective.count(_ % 3 == 1)
  val r2 = detective.count(_ % 3 == 2)

  if (n == r0) println(1)
  else {
    val large = math.max(r1, r2)
    val small = math.min(r1, r2)
    if (large <= small + 2) println(r0 + r1 + r2)
    else println(r0 + small * 2 + 3)
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}
