Winson's Semester 2 has started, and he wants to make plans to ace his studies and win the Dean's "Most Locked In" award.
Semester 2 consists of days. On the -th day, , Winson will choose exactly one of his four units to attend a lecture on:
- Unit A: gain knowledge points
- Unit B: gain knowledge points
- Unit C: gain knowledge points
- Unit D: gain knowledge points
Due to his dwindling attention span, Winson is unable to attend a lecture on the same unit two or more days in a row. That is, on the -th day, where , he cannot choose to attend the same lecture as he did on the -th day.
Find the maximum total knowledge points that Winson can gain over the semester.
Input
The first line contains an integer , the number of days in Semester 2. The following lines contain integers , the number of knowledge points winson can gain by attending a unit's lecture on the th day.
Output
Output the maximum total knowledge points that Winson can gain over the semester.
Constraints
Example 1
Input
3
1 2 3 4
2 4 6 8
1 3 5 7
Output
17
If Winson chooses to go to Unit D's lecture on the first day, unit C's lecture on the second day, then unit D's lecture on the third day, he will obtain 4 + 6 + 7 = 17 knowledge points.
Example 2
Input
1
2102 2014 2004 2099
Output
2102
Example 3
Input
7
3 1 4 10
4 10 6 8
1 4 7 1
3 10 5 6
10 3 1 9
1 10 9 3
4 11 9 5
Output
67
Comments