Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.
The vacation consists of N days. For each i (1≤i≤N), Taro will choose one of the following activities and do it on the i-th day:
- Swim in the sea. Gain ai points of happiness.
- Catch bugs in the mountains. Gain bi points of happiness.
- Do homework at home. Gain ci points of happiness.
As Taro gets bored easily, he cannot do the same activities for two or more consecutive days.
Find the maximum possible total points of happiness that Taro gains.
All values in input are integers.
-
1≤N≤105
-
1 ≤ai, bi, ci≤ 104
N
a1 b1 c1
a2 b2 c2
a3 b3 c3
.
.
.
aN bN cN
Print the maximum possible total points of happiness that Taro gains.
Input
3
10 40 70
20 50 80
30 60 90
Output
210
Explaination
If Taro does activities in the order C, B, C, he will gain 70+50+90=210 points of happiness.
This problem is taken from an online judge atcoder. Feel free to try it on your own before moving to solution
Problem link https://atcoder.jp/contests/dp/tasks/dp_c