import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

a=[[0],[0],[0]]

n = int(eval(input()))

for i in range(n):

    A,B,C = list(map(int,input().split()))

    a[0].append(A)

    a[1].append(B)

    a[2].append(C)

dp = []

for j in range(n+1):

    dp.append([0,0,0])



dp[1][0] = a[0][1]

dp[1][1] = a[1][1]

dp[1][2] = a[2][1]

for i in range(2,n+1):

    for j in range(3):

        x = dp[i-1][(j+1)%3]+a[j][i]

        y = dp[i-1][(j+2)%3]+a[j][i]

        dp[i][j] = max(x,y)

print((max(dp[n][0],dp[n][1],dp[n][2])))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



a,b,c = 0,0,0

n = int(eval(input()))

for i in range(n):

    x,y,z = list(map(int,input().split()))

    a,b,c = max(b,c)+x,max(a,c)+y,max(a,b)+z



print((max(a,b,c)))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a = [[0], [0], [0]]
n = int(eval(input()))
for i in range(n):
    A, B, C = list(map(int, input().split()))
    a[0].append(A)
    a[1].append(B)
    a[2].append(C)
dp = []
for j in range(n + 1):
    dp.append([0, 0, 0])
dp[1][0] = a[0][1]
dp[1][1] = a[1][1]
dp[1][2] = a[2][1]
for i in range(2, n + 1):
    for j in range(3):
        x = dp[i - 1][(j + 1) % 3] + a[j][i]
        y = dp[i - 1][(j + 2) % 3] + a[j][i]
        dp[i][j] = max(x, y)
print((max(dp[n][0], dp[n][1], dp[n][2])))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b, c = 0, 0, 0
n = int(eval(input()))
for i in range(n):
    x, y, z = list(map(int, input().split()))
    a, b, c = max(b, c) + x, max(a, c) + y, max(a, b) + z
print((max(a, b, c)))

-a = [[0], [0], [0]] +a, b, c = 0, 0, 0 -    A, B, C = list(map(int, input().split())) -    a[0].append(A) -    a[1].append(B) -    a[2].append(C) -dp = [] -for j in range(n + 1): -    dp.append([0, 0, 0]) -dp[1][0] = a[0][1] -dp[1][1] = a[1][1] -dp[1][2] = a[2][1] -for i in range(2, n + 1): -    for j in range(3): -        x = dp[i - 1][(j + 1) % 3] + a[j][i] -        y = dp[i - 1][(j + 2) % 3] + a[j][i] -        dp[i][j] = max(x, y) -print((max(dp[n][0], dp[n][1], dp[n][2]))) +    x, y, z = list(map(int, input().split())) +    a, b, c = max(b, c) + x, max(a, c) + y, max(a, b) + z +print((max(a, b, c)))