import sys

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



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

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

for col in range(3):

    dp[0][col] = L[0][col]

#print(dp)



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])))
#DP C

import sys

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

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

#print(L)



dp = [[0,0,0] for _ in range(N)]

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

for i in range(1, N):

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

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

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

    #print(dp)

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

n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [[0 for i in range(3)] for j in range(n)]
for col in range(3):
    dp[0][col] = L[0][col]
# print(dp)
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])))

# DP C
import sys

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

+# DP C -n = int(sys.stdin.readline()) -L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] -dp = [[0 for i in range(3)] for j in range(n)] -for col in range(3): -    dp[0][col] = L[0][col] -# print(dp) -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] +N = int(sys.stdin.readline()) +L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)] +# print(L) +dp = [[0, 0, 0] for _ in range(N)] +dp[0] = L[0].copy() +for i in range(1, N): +    dp[i][0] = L[i][0] + max(dp[i - 1][1], dp[i - 1][2]) +    dp[i][1] = L[i][1] + max(dp[i - 1][0], dp[i - 1][2]) +    dp[i][2] = L[i][2] + max(dp[i - 1][0], dp[i - 1][1]) +    # print(dp)