What makes a great application? Extracurriculars. Throughout his 4 years in high school, Ace has participated in extracurriculars. Unfortunately, the application only allows him to talk about four of them. Thus, Ace chooses to talk about one extracurricular per grade. In every club, for every year he has participated in it, he is given an excellency score for his enthusiasm . If Ace did not participate in that club for a grade, the score value will be (Ace is guaranteed to have participated in the club for at least 1 year). Ace cannot use one club for more than one grade (each grade has to be represented by a unique club). Find the maximum combined excellency score for the four years so that Ace can show the most of his extracurriculars.
Input Specification
First line: integer , the number of extracurriculars Ace has done.
Next lines: four integers , , , and . is his excellency score in that club in grade 9, for grade 10, for grade 11, and for grade 12.
Output Specification
The maximum total excellency Ace can achieve.
Sample Input 1
4
7 6 8 10
4 10 10 5
9 4 4 4
2 1 2 1
Sample Output 1
31
Explanation
For grade 9, Ace chooses club # (excellency = 9), for grade 10, Ace chooses club # (excellency = 10), for grade 11, Ace chooses club # (excellency = 2) and for grade 12, Ace chooses club # (excellency = 10) for a grand total of 31 excellency points.
Sample Input 2
6
5 5 4 5
8 6 6 6
7 0 -1 -1
-1 -1 -1 5
8 8 -1 8
10 0 0 4
Sample Output 2
29
Sample Input 3
2
8 8 6 6
6 8 6 6
Sample Output 3
16
Comments
I wonder what school's gonna reject him, given his 100000 extracurriculars