object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.toInt).toList.init
        val (x, y) = Array((30, 160), (20, 140), (10, 125)).unzip
        in.foreach(n => println(3130-(x.scanLeft((n, n))((a, b) => (a._2-b max 0, a._2 min b)).tail.map(_._1) zip y).map(p => p._1 * p._2).sum))
    }
}