n=int(eval(input()))

al=[0]+[list(map(int,input().split())) for _ in range(n)]

dp=[[0,0,0] for _ in range(n+1)]

for day in range(1,n+1):

  for i in range(3):

    for j in range(3):

      if i==j:continue

      dp[day][i]=max(dp[day-1][j]+al[day][i],dp[day][i])

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

input=sys.stdin.readline

n=int(eval(input()))

l=[[float("INF")]*3 for i in range(n)]

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

for day in range(1,n):

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

    for choice in range(3):

        l[day][choice]=max(l[day-1][j]+f[choice] for j in range(3) if j!=choice)

print((max(l[-1])))
n = int(eval(input()))
al = [0] + [list(map(int, input().split())) for _ in range(n)]
dp = [[0, 0, 0] for _ in range(n + 1)]
for day in range(1, n + 1):
    for i in range(3):
        for j in range(3):
            if i == j:
                continue
            dp[day][i] = max(dp[day - 1][j] + al[day][i], dp[day][i])
print((max(dp[-1])))

import sys

input = sys.stdin.readline
n = int(eval(input()))
l = [[float("INF")] * 3 for i in range(n)]
l[0] = list(map(int, input().split()))
for day in range(1, n):
    f = list(map(int, input().split()))
    for choice in range(3):
        l[day][choice] = max(l[day - 1][j] + f[choice] for j in range(3) if j != choice)
print((max(l[-1])))

+import sys + +input = sys.stdin.readline -al = [0] + [list(map(int, input().split())) for _ in range(n)] -dp = [[0, 0, 0] for _ in range(n + 1)] -for day in range(1, n + 1): -    for i in range(3): -        for j in range(3): -            if i == j: -                continue -            dp[day][i] = max(dp[day - 1][j] + al[day][i], dp[day][i]) -print((max(dp[-1]))) +l = [[float("INF")] * 3 for i in range(n)] +l[0] = list(map(int, input().split())) +for day in range(1, n): +    f = list(map(int, input().split())) +    for choice in range(3): +        l[day][choice] = max(l[day - 1][j] + f[choice] for j in range(3) if j != choice) +print((max(l[-1])))