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

  val n = readInt
  val scores = readLine.trim.split(' ').map(_.toInt)
  val dosanko = readLine.trim.split(' ').map(_.toInt) match {case Array(s, p, c) ⇒ TeamParam(s, p, c); case _ ⇒ ???}
  val others = Array.tabulate(n - 1){_ ⇒ readLine.trim.split(' ').map(_.toInt) match {case Array(s, p, c) ⇒ TeamParam(s, p, c); case _ ⇒ ???}}
  val top8 = takeTop8(scores, others)
  val competition = new Competition(scores, others)
  println(
    List(minSmile(competition, dosanko), minCool(competition, dosanko), minPure(competition, dosanko)).flatten.sorted.headOption.map(_.toString).getOrElse("Saiko")
  )
  def minPure(competition: Competition, ninth: TeamParam): Option[Int] = {
    var left = 1
    var right = 101 - ninth.pure
    while (left < right){
      val mid = (left + right) / 2
      if (competition.isRankUp(ninth.copy(pure = ninth.pure + mid))) {
        right = mid
      }else {
        left = mid + 1
      }
    }
    if (competition.isRankUp(ninth.copy(pure = ninth.pure + right))) Some(right) else None
  }
  def minCool(competition: Competition, ninth: TeamParam): Option[Int] = {
    var left = 1
    var right = 101 - ninth.cool
    while(left < right){
      val mid = (left + right) / 2
      if (competition.isRankUp(ninth.copy(cool = ninth.cool + mid))){
        right = mid
      }else {
        left = mid + 1
      }
    }
    if (competition.isRankUp(ninth.copy(cool = ninth.cool + right))) Some(right) else None
  }
  def minSmile(competition: Competition, ninth: TeamParam): Option[Int] = {
    var left = 1
    var right = 101 - ninth.smile
    while(left < right){
      val mid = (left + right) / 2
      if (competition.isRankUp(ninth.copy(smile = ninth.smile + mid))){
        right = mid
      }else {
        left = mid + 1
      }
    }
    if (competition.isRankUp(ninth.copy(smile = ninth.smile + right))) Some(right) else None
  }
  def takeTop8(scores: Array[Int], teams: Array[TeamParam]): Array[TeamParam] = {
    val smiles = teams.map(_.smile).sorted(Ordering.Int.reverse)
    val pures = teams.map(_.pure).sorted(Ordering.Int.reverse)
    val cools = teams.map(_.cool).sorted(Ordering.Int.reverse)
    teams.map(t ⇒ scores(lowerBound(smiles, t.smile)) + scores(lowerBound(pures, t.pure)) + scores(lowerBound(cools, t.cool))).zipWithIndex.sortBy(_._1)(Ordering.Int.reverse).take(8).map(z ⇒ teams(z._2))
  }
  class Competition(val scores: Array[Int], val others: Array[TeamParam]) {
    def isRankUp(ninth: TeamParam): Boolean = {
      val allTeams = others :+ ninth
      val smiles = allTeams.map(_.smile).sorted(Ordering.Int.reverse)
      val pures = allTeams.map(_.pure).sorted(Ordering.Int.reverse)
      val cools = allTeams.map(_.cool).sorted(Ordering.Int.reverse)
      val allScores = allTeams.map(t ⇒ scores(lowerBound(smiles, t.smile)) + scores(lowerBound(pures, t.pure)) + scores(lowerBound(cools, t.cool))).sorted(Ordering.Int.reverse)
      val ninthScore = scores(lowerBound(smiles, ninth.smile)) + scores(lowerBound(pures, ninth.pure)) + scores(lowerBound(cools, ninth.cool))
      lowerBound(allScores, ninthScore) < 8
    }
  }
  def lowerBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length - 1
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) > target){
        left = mid + 1
      }else{
        right = mid
      }
    }
    right
  }
  case class TeamParam(smile: Int, pure: Int, cool: Int)
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 45300