N = int(eval(input()))

a = [0]*N

b = [0]*N

c = [0]*N



for i in range(N):

  a[i], b[i], c[i] = [int(_) for _ in input().split()]

  

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



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

dp[0][1] = b[0]

dp[0][2] = c[0]



for i in range(N-1):

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

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

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

    

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

import sys

input = sys.stdin.readline

n = int(eval(input()))

abc = [tuple(map(int,input().split())) for i in range(n)]



dp_a = [0]*n

dp_b = [0]*n

dp_c = [0]*n



a,b,c = abc[0]

dp_a[0] = a

dp_b[0] = b

dp_c[0] = c



for i in range(1,n):

    a, b, c = abc[i]

    dp_a[i] = max(dp_b[i-1]+a, dp_c[i-1]+a)

    dp_b[i] = max(dp_c[i-1]+b, dp_a[i-1]+b)

    dp_c[i] = max(dp_a[i-1]+c, dp_b[i-1]+c)



print((max(dp_a[-1], dp_b[-1], dp_c[-1])))

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

import sys

input = sys.stdin.readline
n = int(eval(input()))
abc = [tuple(map(int, input().split())) for i in range(n)]
dp_a = [0] * n
dp_b = [0] * n
dp_c = [0] * n
a, b, c = abc[0]
dp_a[0] = a
dp_b[0] = b
dp_c[0] = c
for i in range(1, n):
    a, b, c = abc[i]
    dp_a[i] = max(dp_b[i - 1] + a, dp_c[i - 1] + a)
    dp_b[i] = max(dp_c[i - 1] + b, dp_a[i - 1] + b)
    dp_c[i] = max(dp_a[i - 1] + c, dp_b[i - 1] + c)
print((max(dp_a[-1], dp_b[-1], dp_c[-1])))

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