
object Main extends App {

  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n != 0){
      println(
        Array.tabulate(n){_ ⇒
          val Array(x, y, h, w) = readLine.trim.split(' ').map(_.toInt)
          Package(x, y, h, w) match{
            case FeeRank(fee) ⇒ fee
            case _ ⇒ 0
          }
        }.sum
      )
      solve
    }
  }
  object Package {
    def apply(x: Int, y: Int, h: Int, w: Int): Package = Package(x + y + h, w)
  }
  case class Package(size: Int, weight: Int)
  object FeeRank {
    def unapply(arg: Package): Option[Int] = {
      arg match{
        case Package(size, weight) if size <= 60 && weight <= 2 ⇒ Some(600)
        case Package(size, weight) if size <= 80 && weight <= 5 ⇒ Some(800)
        case Package(size, weight) if size <= 100 && weight <= 10 ⇒ Some(1000)
        case Package(size, weight) if size <= 120 && weight <= 15 ⇒ Some(1200)
        case Package(size, weight) if size <= 140 && weight <= 20 ⇒ Some(1400)
        case Package(size, weight) if size <= 160 && weight <= 25 ⇒ Some(1600)
        case _ ⇒ None
      }
    }
  }
  implicit class ScopeFunc[T](val value:T){
    def let[A](func: T ⇒ A): A = func(value)
  }
}
