N = int(eval(input()))

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

dp[0] = list(map(int,input().split()))

for i in range(1,N):

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

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

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

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

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

readline = sys.stdin.readline

N = int(readline())

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

dp[0] = list(map(int,readline().split()))

for i in range(1,N):

    a,b,c = list(map(int,readline().split()))

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

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

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

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

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

import sys

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

-N = int(eval(input())) +import sys + +readline = sys.stdin.readline +N = int(readline()) -dp[0] = list(map(int, input().split())) +dp[0] = list(map(int, readline().split())) -    a, b, c = list(map(int, input().split())) +    a, b, c = list(map(int, readline().split()))