#import sys

#input = sys.stdin.readline



n = int(eval(input()))

abc = []

for i in range(n):

    abc.append([int(i) for i in input().split()])

dp = [[float("inf") for i in range(3)] for i in range(n)]



dp[0] = abc[0]

for i in range(n-1):

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

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

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

    

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

#import sys

#input = sys.stdin.readline



n = int(eval(input()))



for i in range(n):

    if i == 0:

        dp = [int(i) for i in input().split()]

    else:

        abc = [int(i) for i in input().split()]

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

    

print((max(dp)))



# import sys
# input = sys.stdin.readline
n = int(eval(input()))
abc = []
for i in range(n):
    abc.append([int(i) for i in input().split()])
dp = [[float("inf") for i in range(3)] for i in range(n)]
dp[0] = abc[0]
for i in range(n - 1):
    dp[i + 1][0] = abc[i + 1][0] + max(dp[i][1], dp[i][2])
    dp[i + 1][1] = abc[i + 1][1] + max(dp[i][0], dp[i][2])
    dp[i + 1][2] = abc[i + 1][2] + max(dp[i][0], dp[i][1])
print((max(dp[-1])))

# import sys
# input = sys.stdin.readline
n = int(eval(input()))
for i in range(n):
    if i == 0:
        dp = [int(i) for i in input().split()]
    else:
        abc = [int(i) for i in input().split()]
        dp[0], dp[1], dp[2] = (
            abc[0] + max(dp[1], dp[2]),
            abc[1] + max(dp[0], dp[2]),
            abc[2] + max(dp[0], dp[1]),
        )
print((max(dp)))

-abc = [] -    abc.append([int(i) for i in input().split()]) -dp = [[float("inf") for i in range(3)] for i in range(n)] -dp[0] = abc[0] -for i in range(n - 1): -    dp[i + 1][0] = abc[i + 1][0] + max(dp[i][1], dp[i][2]) -    dp[i + 1][1] = abc[i + 1][1] + max(dp[i][0], dp[i][2]) -    dp[i + 1][2] = abc[i + 1][2] + max(dp[i][0], dp[i][1]) -print((max(dp[-1]))) +    if i == 0: +        dp = [int(i) for i in input().split()] +    else: +        abc = [int(i) for i in input().split()] +        dp[0], dp[1], dp[2] = ( +            abc[0] + max(dp[1], dp[2]), +            abc[1] + max(dp[0], dp[2]), +            abc[2] + max(dp[0], dp[1]), +        ) +print((max(dp)))