N = int(eval(input()))

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



dp = [[0]*3 for _ in range(100010)] 

# dp[i][j] : i日目にj番目の活動をしたときの幸福度の総和

idx = [[1,2],[2,0],[0,1]]



for i in range(3):

    dp[0][i] = a[0][i]

    

for i in range(1,N):

    for j in range(3):

        dp[i][j] = max(dp[i-1][idx[j][0]],dp[i-1][idx[j][1]])+a[i][j]

    

print((max(dp[N-1])))
import sys

def input():

    return sys.stdin.readline()[:-1]



N = int(eval(input()))

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



inf = 10**9+7

dp = [[0] * 3 for _ in range(N+10)]

dp[0] = [ABC[0][0],ABC[0][1],ABC[0][2]]



for i in range(N-1):

    for j in range(3):

        for k in range(3):

            if j==k:continue

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

        

    



print((max(dp[N-1][:])))

N = int(eval(input()))
a = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * 3 for _ in range(100010)]
# dp[i][j] : i日目にj番目の活動をしたときの幸福度の総和
idx = [[1, 2], [2, 0], [0, 1]]
for i in range(3):
    dp[0][i] = a[0][i]
for i in range(1, N):
    for j in range(3):
        dp[i][j] = max(dp[i - 1][idx[j][0]], dp[i - 1][idx[j][1]]) + a[i][j]
print((max(dp[N - 1])))

import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(eval(input()))
ABC = [list(map(int, input().split())) for _ in range(N)]
inf = 10**9 + 7
dp = [[0] * 3 for _ in range(N + 10)]
dp[0] = [ABC[0][0], ABC[0][1], ABC[0][2]]
for i in range(N - 1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + ABC[i + 1][j])
print((max(dp[N - 1][:])))

+import sys + + +def input(): +    return sys.stdin.readline()[:-1] + + -a = [list(map(int, input().split())) for _ in range(N)] -dp = [[0] * 3 for _ in range(100010)] -# dp[i][j] : i日目にj番目の活動をしたときの幸福度の総和 -idx = [[1, 2], [2, 0], [0, 1]] -for i in range(3): -    dp[0][i] = a[0][i] -for i in range(1, N): +ABC = [list(map(int, input().split())) for _ in range(N)] +inf = 10**9 + 7 +dp = [[0] * 3 for _ in range(N + 10)] +dp[0] = [ABC[0][0], ABC[0][1], ABC[0][2]] +for i in range(N - 1): -        dp[i][j] = max(dp[i - 1][idx[j][0]], dp[i - 1][idx[j][1]]) + a[i][j] -print((max(dp[N - 1]))) +        for k in range(3): +            if j == k: +                continue +            dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + ABC[i + 1][j]) +print((max(dp[N - 1][:])))