N = int(eval(input()))

A = [list(map(int, input().split())) for i in range(N)]

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

for i in range(1,N+1):

  for j in range(3):

    for k in range(3):

      if j != k:

        dp[i][k] = max(dp[i][k],dp[i-1][j]+A[i-1][k])

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

input = sys.stdin.readline

N = int(eval(input()))

table = []

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



for i in range(N):

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

    table.append((a,b,c))



dp[0] = table[0]

for i in range(1,N):

    for j in range(3):

        for k in range(3):

            if j==k:

                continue

            dp[i][j] = max(dp[i][j],dp[i-1][k]+table[i][j])

print((max(dp[-1])))
N = int(eval(input()))
A = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i - 1][k])
print((max(dp[-1])))

import sys

input = sys.stdin.readline
N = int(eval(input()))
table = []
dp = [[0] * 3 for i in range(N)]
for i in range(N):
    a, b, c = list(map(int, input().split()))
    table.append((a, b, c))
dp[0] = table[0]
for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + table[i][j])
print((max(dp[-1])))

+import sys + +input = sys.stdin.readline -A = [list(map(int, input().split())) for i in range(N)] -dp = [[0] * 3 for i in range(N + 1)] -for i in range(1, N + 1): +table = [] +dp = [[0] * 3 for i in range(N)] +for i in range(N): +    a, b, c = list(map(int, input().split())) +    table.append((a, b, c)) +dp[0] = table[0] +for i in range(1, N): -            if j != k: -                dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i - 1][k]) +            if j == k: +                continue +            dp[i][j] = max(dp[i][j], dp[i - 1][k] + table[i][j])