import numpy as np

import sys



stdin = sys.stdin

 

sn = lambda : stdin.readline().rstrip()

an = lambda : list(map(int, stdin.readline().split()))

ni = lambda : int(sn())



N = ni()

ABC = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for i in range(3)] for j in range(N+1)]



def chmax(a, b):

    if a > b:

        return a

    else:

        return b



for i in range(N):

    for j in range(3):

        for k in range(3):

            if j == k:

                continue

            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + ABC[i][k])



ans = 0

for i in range(3):

    ans = max(ans,dp[N][i])



print(ans)
# C - Vacation

n=int(eval(input()))

abc=[list(map(int,input().split())) for i in range(n)]

# i日目にjを選んだ場合の幸福度の総和をdp[i][j]とする。

dp=[[0]*3 for i in range(n+1)]

for i in range(n):

    for j in range(3):

        for k in range(3):

            if j==k:continue

            dp[i+1][k]=max(dp[i+1][k],dp[i][j]+abc[i][k])

ans=0

for i in range(3):

    ans=max(ans,dp[n][i])

print(ans)

import numpy as np
import sys

stdin = sys.stdin
sn = lambda: stdin.readline().rstrip()
an = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(sn())
N = ni()
ABC = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for i in range(3)] for j in range(N + 1)]


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + ABC[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[N][i])
print(ans)

# C - Vacation
n = int(eval(input()))
abc = [list(map(int, input().split())) for i in range(n)]
# i日目にjを選んだ場合の幸福度の総和をdp[i][j]とする。
dp = [[0] * 3 for i in range(n + 1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[n][i])
print(ans)

-import numpy as np -import sys - -stdin = sys.stdin -sn = lambda: stdin.readline().rstrip() -an = lambda: list(map(int, stdin.readline().split())) -ni = lambda: int(sn()) -N = ni() -ABC = [list(map(int, input().split())) for i in range(N)] -dp = [[0 for i in range(3)] for j in range(N + 1)] - - -def chmax(a, b): -    if a > b: -        return a -    else: -        return b - - -for i in range(N): +# C - Vacation +n = int(eval(input())) +abc = [list(map(int, input().split())) for i in range(n)] +# i日目にjを選んだ場合の幸福度の総和をdp[i][j]とする。 +dp = [[0] * 3 for i in range(n + 1)] +for i in range(n): -            dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + ABC[i][k]) +            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]) -    ans = max(ans, dp[N][i]) +    ans = max(ans, dp[n][i])