n = int(eval(input()))



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

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

dp[0] = [a,b,c]

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[-1])))
import sys

readline = sys.stdin.buffer.readline

def even(n): return 1 if n%2==0 else 0



n = int(readline())

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

lst1 = list(map(int,readline().split()))

for i in range(3):

	dp[0][i] = lst1[i]

for i in range(n-1):

	lst1 = list(map(int,readline().split()))

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

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

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



print((max(dp[-1])))
n = int(eval(input()))
dp = [[0] * 3 for i in range(n)]
a, b, c = list(map(int, input().split()))
dp[0] = [a, b, c]
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[-1])))

import sys

readline = sys.stdin.buffer.readline


def even(n):
    return 1 if n % 2 == 0 else 0


n = int(readline())
dp = [[0] * 3 for _ in range(n)]
lst1 = list(map(int, readline().split()))
for i in range(3):
    dp[0][i] = lst1[i]
for i in range(n - 1):
    lst1 = list(map(int, readline().split()))
    dp[i + 1][0] = max(dp[i][1] + lst1[0], dp[i][2] + lst1[0])
    dp[i + 1][1] = max(dp[i][0] + lst1[1], dp[i][2] + lst1[1])
    dp[i + 1][2] = max(dp[i][0] + lst1[2], dp[i][1] + lst1[2])
print((max(dp[-1])))

-n = int(eval(input())) -dp = [[0] * 3 for i in range(n)] -a, b, c = list(map(int, input().split())) -dp[0] = [a, b, c] -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 +import sys + +readline = sys.stdin.buffer.readline + + +def even(n): +    return 1 if n % 2 == 0 else 0 + + +n = int(readline()) +dp = [[0] * 3 for _ in range(n)] +lst1 = list(map(int, readline().split())) +for i in range(3): +    dp[0][i] = lst1[i] +for i in range(n - 1): +    lst1 = list(map(int, readline().split())) +    dp[i + 1][0] = max(dp[i][1] + lst1[0], dp[i][2] + lst1[0]) +    dp[i + 1][1] = max(dp[i][0] + lst1[1], dp[i][2] + lst1[1]) +    dp[i + 1][2] = max(dp[i][0] + lst1[2], dp[i][1] + lst1[2])