N=int(eval(input()))

a=[]

for _ in range(N): 

    b=list(map(int,input().split()))

    a.append(b)

dp=[]

for _ in range(N):

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

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

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

dp[0][2]=a[0][2]

for i in range(1,N):

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

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

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

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

input = sys.stdin.readline



n = int(eval(input()))

abc = [[int(x) for x in input().split()] for _ in range(n)]



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

dp[0][0] = abc[0][0]

dp[0][1] = abc[0][1]

dp[0][2] = abc[0][2]



for i in range(1, n):

    a, b, c = abc[i]

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

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

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



print((max(dp[-1])))
N = int(eval(input()))
a = []
for _ in range(N):
    b = list(map(int, input().split()))
    a.append(b)
dp = []
for _ in range(N):
    dp.append([0, 0, 0])
dp[0][0] = a[0][0]
dp[0][1] = a[0][1]
dp[0][2] = a[0][2]
for i in range(1, N):
    dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0])
    dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1])
    dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2])
print((max(dp[N - 1][0], dp[N - 1][1], dp[N - 1][2])))

import sys

input = sys.stdin.readline
n = int(eval(input()))
abc = [[int(x) for x in input().split()] for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    a, b, c = abc[i]
    dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
    dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
    dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
print((max(dp[-1])))

-N = int(eval(input())) -a = [] -for _ in range(N): -    b = list(map(int, input().split())) -    a.append(b) -dp = [] -for _ in range(N): -    dp.append([0, 0, 0]) -dp[0][0] = a[0][0] -dp[0][1] = a[0][1] -dp[0][2] = a[0][2] -for i in range(1, N): -    dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]) -    dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]) -    dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2]) -print((max(dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]))) +import sys + +input = sys.stdin.readline +n = int(eval(input())) +abc = [[int(x) for x in input().split()] for _ in range(n)] +dp = [[0] * 3 for _ in range(n)] +dp[0][0] = abc[0][0] +dp[0][1] = abc[0][1] +dp[0][2] = abc[0][2] +for i in range(1, n): +    a, b, c = abc[i] +    dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a) +    dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b) +    dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c) +print((max(dp[-1])))