import sys

n = int(sys.stdin.readline())

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]



p = [[0 for _ in range(3)] for _ in range(n)]



p[0] = L[0].copy()

#print(p)

#print(L)



for d in range(1, n):

    for i in range(3):

        if i ==0:

            p[d][0] = max(p[d-1][1], p[d-1][2]) + L[d][0]

        elif i ==1:

            p[d][1] = max(p[d-1][0], p[d-1][2]) + L[d][1]

        elif i==2:

            p[d][2] = max(p[d-1][0], p[d-1][1]) + L[d][2]



print((max(p[-1])))
import sys

n = int(sys.stdin.readline())

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]

#print(L)



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

dp[0] = L[0].copy()



for i in range(1,n):

    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + L[i][0]

    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + L[i][1]

    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + L[i][2]



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

n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
p = [[0 for _ in range(3)] for _ in range(n)]
p[0] = L[0].copy()
# print(p)
# print(L)
for d in range(1, n):
    for i in range(3):
        if i == 0:
            p[d][0] = max(p[d - 1][1], p[d - 1][2]) + L[d][0]
        elif i == 1:
            p[d][1] = max(p[d - 1][0], p[d - 1][2]) + L[d][1]
        elif i == 2:
            p[d][2] = max(p[d - 1][0], p[d - 1][1]) + L[d][2]
print((max(p[-1])))

import sys

n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
# print(L)
dp = [[0 for _ in range(3)] for _ in range(n)]
dp[0] = L[0].copy()
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + L[i][0]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + L[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + L[i][2]
print((max(dp[-1])))

-p = [[0 for _ in range(3)] for _ in range(n)] -p[0] = L[0].copy() -# print(p) -for d in range(1, n): -    for i in range(3): -        if i == 0: -            p[d][0] = max(p[d - 1][1], p[d - 1][2]) + L[d][0] -        elif i == 1: -            p[d][1] = max(p[d - 1][0], p[d - 1][2]) + L[d][1] -        elif i == 2: -            p[d][2] = max(p[d - 1][0], p[d - 1][1]) + L[d][2] -print((max(p[-1]))) +dp = [[0 for _ in range(3)] for _ in range(n)] +dp[0] = L[0].copy() +for i in range(1, n): +    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + L[i][0] +    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + L[i][1] +    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + L[i][2] +print((max(dp[-1])))