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 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day:

* A: Swim in the sea. Gain a_i points of happiness.
* B: Catch bugs in the mountains. Gain b_i points of happiness.
* C: Do homework at home. Gain c_i 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.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq a_i, b_i, c_i \leq 10^4

Input

Input is given from Standard Input in the following format:


N
a_1 b_1 c_1
a_2 b_2 c_2
:
a_N b_N c_N


Output

Print the maximum possible total points of happiness that Taro gains.

Examples

Input

3
10 40 70
20 50 80
30 60 90


Output

210


Input

1
100 10 1


Output

100


Input

7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1


Output

46
"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival"
from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream


if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip


def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    n=int(input())
    l1=[]
    for i in range(n):
        l1.append(list(map(int,input().split())))
    dp=[ [0]*3 for _ in range(n)]
    dp[0]=l1[0]
    for i in range(1,n):
        dp[i][0]=l1[i][0]+max(dp[i-1][1],dp[i-1][2])
        dp[i][1]=l1[i][1]+max(dp[i-1][0],dp[i-1][2])
        dp[i][2]=l1[i][2]+max(dp[i-1][0],dp[i-1][1])
    print(max(dp[-1]))
if __name__ == '__main__':
    sync_with_stdio(False)
    main()