Under construction

Still being built. Things may change

Skateboard

Interview

Time limit1sMemory limit1024 MB

Summary
Given each athlete's two run scores and five trick scores, find the highest final score, where each final score is the best run plus the top two tricks.
Level

Easy2 of 10

Topics
Implementation, Sorting
Solved
No attempts yet

Problem

Skateboarding has been an Olympic sport since 2020, divided into street and park events. Street skating has athletes perform tricks using structures such as stairs, handrails, rails, and ramps. The street scoring works as follows.

  • Each athlete makes two runs and five trick attempts, each scored from 00 to 100100.
  • The final score is the sum of three scores: the higher of the two run scores, plus the top two of the five trick scores.
  • The athlete with the highest final score wins. If several athletes share the highest score, they tie for first.

Given the score sheet of the competitors, find the final score of the winner.

Input

The first line contains the number of athletes NN. (1≤N≤100 000)(1 \leq N \leq 100\,000)

From the second line, the next NN lines each contain seven integers separated by spaces: the scores of two runs followed by five trick scores, in that order. (0≤score≤100)(0 \leq \text{score} \leq 100)

Output

Print the final score of the winner on the first line.

Examples1

  1. Example 1

    Input
    2
    1 2 4 2 3 1 1
    5 5 5 5 5 5 5
    
    Expected output
    15